mirror of
https://github.com/espruino/Espruino.git
synced 2025-12-08 19:06:15 +00:00
DataView#getUint32() sign-bit fix
This commit is contained in:
parent
d66db87dc2
commit
d2e949c947
@ -372,7 +372,7 @@ JsVar *jsvArrayBufferIteratorGetValue(JsvArrayBufferIterator *it) {
|
||||
return jsvNewFromFloat(jsvArrayBufferIteratorDataToFloat(it, data));
|
||||
} else {
|
||||
JsVarInt i = jsvArrayBufferIteratorDataToInt(it, data);
|
||||
if (it->type == ARRAYBUFFERVIEW_UINT32)
|
||||
if ((it->type & ~ARRAYBUFFERVIEW_BIG_ENDIAN) == ARRAYBUFFERVIEW_UINT32)
|
||||
return jsvNewFromLongInteger((long long)(uint32_t)i);
|
||||
return jsvNewFromInteger(i);
|
||||
}
|
||||
|
||||
@ -44,5 +44,9 @@ d.setUint32(0,0x12345678,true)
|
||||
test("d.getUint32(0,true)", "0x12345678");
|
||||
d.setUint32(0,0x12345678)
|
||||
test("d.getUint32(0)", "0x12345678");
|
||||
d.setUint32(0,0xffff5678,true) // sign-bit value
|
||||
test("d.getUint32(0,true)", "0xffff5678");
|
||||
d.setUint32(0,0xffff5678) // sign-bit value
|
||||
test("d.getUint32(0)", "0xffff5678");
|
||||
|
||||
result = testsRun==testsPass;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user