By truncating you mean producing an 8 bit number - turning 5000 into 136, rather than 19 and 136?
I think so - E.toX takes whatever you give it, and should produce something with the same number of elements. I think if you did:
E.toX
a = new Uint16Array(4); a[1] = 4; b = E.toUint8Array(a); console.log(b[1]);
You'd expect to get 4 returned.
4
As you found, if you want to get at the untruncated byte data of a UintXArray, you can just access array.buffer
array.buffer
@Gordon started
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
By truncating you mean producing an 8 bit number - turning 5000 into 136, rather than 19 and 136?
I think so -
E.toX
takes whatever you give it, and should produce something with the same number of elements. I think if you did:You'd expect to get
4
returned.As you found, if you want to get at the untruncated byte data of a UintXArray, you can just access
array.buffer