Skip to content

Commit

Permalink
Fix error when the biteWidth is bigger than float 32, it should switc…
Browse files Browse the repository at this point in the history
…h to 64 like the other implementations
  • Loading branch information
fran6co committed Mar 18, 2024
1 parent 67eb95d commit 986d08b
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion ts/flexbuffers/stack-value.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 986d08b

Please sign in to comment.