I have a standard JavaScript array filled with valid 32-bit signed integers that I need to convert into a UInt8Array
. Take for example this JavaScript array:
[255, 3498766, -99]
The resulting UInt8Array
should display the signed 32-bit representation of these numbers:
255 = [0x00, 0x00, 0x00, 0xFF]
3498766 = [0x00, 0x35, 0x63, 0x0E]
-99 = [0xFF, 0xFF, 0xFF, 0x9D]
Therefore, if given an input of [255, 3498766, -99]
, the output would be:
[0x00, 0x00, 0x00, 0xFF, 0x00, 0x35, 0x63, 0x0E, 0xFF, 0xFF, 0xFF, 0x9D]
While there are more straightforward ways to achieve this task, I am interested in finding the most direct conversion method.