domoritz commented on code in PR #40729:
URL: https://github.com/apache/arrow/pull/40729#discussion_r1537920807


##########
js/test/unit/bn-tests.ts:
##########
@@ -83,4 +83,19 @@ describe(`BN`, () => {
         const d4 = toDecimal(new Uint32Array([0x9D91E773, 0x4BB90CED, 
0xAB2354CC, 0x54278E9B]));
         expect(d4.toString()).toBe('111860543658909349380118287427608635251');
     });
+
+    test(`valueOf for decimal numbers`, () => {
+        const n1 = new BN(new Uint32Array([0x00000001, 0x00000000, 0x00000000, 
0x00000000]), false);
+        expect(n1.valueOf()).toBe(1);
+        const n2 = new BN(new Uint32Array([0xFFFFFFFE, 0xFFFFFFFF, 0xFFFFFFFF, 
0xFFFFFFFF]), true);
+        expect(n2.valueOf()).toBe(-2);
+        const n3 = new BN(new Uint32Array([0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 
0xFFFFFFFF]), true);
+        expect(n3.valueOf()).toBe(-1);
+        const n4 = new BN(new Uint32Array([0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 
0xFFFFFFFF]), true);
+        expect(n4.valueOf(1)).toBe(-0.1);
+        const n5 = new BN(new Uint32Array([0x00000000, 0x00000000, 0x00000000, 
0x80000000]), false);
+        expect(n5.valueOf()).toBe(1.7014118346046923e+38);
+        // const n6 = new BN(new Uint32Array([0x00000000, 0x00000000, 
0x00000000, 0x80000000]), false);
+        // expect(n6.valueOf(1)).toBe(1.7014118346046923e+37);

Review Comment:
   > Because the CI tool expects all transformations to be reversible and
   converting from a decimal to a number is a one way operation - so I had to
   comment it out.
   
   I don't understand. What does reversible mean here? Will this ever work or 
should we just delete it? 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to