Fix a bug where a floating point number was cast to int and the value was stored incorrectly because of low byte width. (#7703)

Reported in https://github.com/google/flatbuffers/issues/7690
This commit is contained in:
Maxim Zaks
2022-12-13 06:20:26 +01:00
committed by GitHub
parent 3be296ec8a
commit 97ee210826
3 changed files with 6 additions and 1 deletions

View File

@@ -37,6 +37,7 @@ void main() {
// expect(FlxValue.fromBuffer(b([255, 255, 255, 255, 255, 255, 255, 255, 11, 8])).intValue, 18446744073709551615);
});
test('double value', () {
expect(Reference.fromBuffer(b([0, 0, 128, 63, 14, 4])).doubleValue, 1.0);
expect(Reference.fromBuffer(b([0, 0, 144, 64, 14, 4])).doubleValue, 4.5);
expect(Reference.fromBuffer(b([205, 204, 204, 61, 14, 4])).doubleValue,
closeTo(.1, .001));