How does this js code change a 32-bit data stream into a 16-bit data stream?

  /**
   *  32  16 
   * @param {ByteArray} chunk 
   */
  static bit32to16(chunk) {
    const b16 = new Int16Array(chunk.byteLength / 4);
    const dv = new DataView(chunk.buffer);
    for (let i = 0, offset = 0; offset < chunk.byteLength; iPP, offset += 4){
        const v = dv.getFloat32(offset, true);
        b16[i] = v > 0 ? v * 32767 : v * 32768;
    }
    return b16.buffer
  }
The

view is mainly used to manipulate binary data, which is relatively rare in general.
to explain that this method involves a lot of concepts, it is recommended to calm down and understand it when you have time. Use it directly if you don't have time, and you don't have to care about the specific implementation.
this is the information URL: ArrayBuffer introduction .

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b375db-4ecf1.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b375db-4ecf1.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?