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


##########
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:
   > I don't understand. What does reversible mean here? Will this ever work or 
should we just delete it?
   
   The CI tool does not allow transformations from BigInt to number as data 
(correctly) will be lost. What the CI tool is not smart enough to realize is, 
this is on purpose.
   
   It's important that people still realize this is still possible and 
testable, so removing it from the test is not as good an option as leaving this 
commented out in the test.
   
   I think considering we have a very broken library at present, this should 
probably not be of consequence. So whatever you prefer. My preference is to get 
the fix in and we can talk about this later.
   



-- 
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