From 986d08b6315042bd6d49652c52895236d7332e99 Mon Sep 17 00:00:00 2001 From: Francisco Facioni Date: Mon, 18 Mar 2024 09:25:47 +0100 Subject: [PATCH] Fix error when the biteWidth is bigger than float 32, it should switch to 64 like the other implementations --- ts/flexbuffers/stack-value.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ts/flexbuffers/stack-value.ts b/ts/flexbuffers/stack-value.ts index 010641701b0..26d43811ba6 100644 --- a/ts/flexbuffers/stack-value.ts +++ b/ts/flexbuffers/stack-value.ts @@ -26,7 +26,8 @@ export class StackValue { writeToBuffer(byteWidth: number): void { const newOffset = this.builder.computeOffset(byteWidth); if (this.type === ValueType.FLOAT) { - if (this.width === BitWidth.WIDTH32) { + const bitWidth = fromByteWidth(byteWidth); + if (bitWidth === BitWidth.WIDTH32) { this.builder.view.setFloat32(this.builder.offset, this.value as number, true); } else { this.builder.view.setFloat64(this.builder.offset, this.value as number, true);