From d94eca996ffb474305c5c0883a2cb3b90146fa22 Mon Sep 17 00:00:00 2001 From: Kevin De Porre Date: Tue, 28 Nov 2023 09:30:09 +0100 Subject: [PATCH] Add comment to float test regarding float4 value that is read. --- .../typescript/test/client/conversions/sqlite.test.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/clients/typescript/test/client/conversions/sqlite.test.ts b/clients/typescript/test/client/conversions/sqlite.test.ts index b93590a555..bc06564655 100644 --- a/clients/typescript/test/client/conversions/sqlite.test.ts +++ b/clients/typescript/test/client/conversions/sqlite.test.ts @@ -209,7 +209,14 @@ test.serial('floats are converted correctly to SQLite', async (t) => { args: [], }) t.deepEqual(rawRes, [ - { id: 1, float4: Math.fround(1.234), float8: 1.234 }, + // 1.234 cannot be stored exactly in a float4 + // hence, there is a rounding error, which is observed when we + // read the float4 value back into a 64-bit JS number + // The value 1.2339999675750732 that we read back + // is also what Math.fround(1.234) returns + // as being the nearest 32-bit single precision + // floating point representation of 1.234 + { id: 1, float4: 1.2339999675750732, float8: 1.234 }, { id: 2, float4: 'NaN', float8: 'NaN' }, { id: 3, float4: Infinity, float8: Infinity }, { id: 4, float4: -Infinity, float8: -Infinity },