trxcllnt commented on code in PR #45251:
URL: https://github.com/apache/arrow/pull/45251#discussion_r1920506254


##########
js/src/util/bn.ts:
##########
@@ -91,15 +91,25 @@ export function bigNumToNumber<T extends 
BN<BigNumArray>>(bn: T, scale?: number)
             number |= word * (BigInt(1) << BigInt(64 * i++));
         }
     }
-    if (typeof scale === 'number') {
-        const denominator = BigInt(Math.pow(10, scale));
+    if (typeof scale === 'number' && scale > 0) {
+        const denominator = BigInt('1' + '0'.repeat(scale));
         const quotient = number / denominator;
-        const remainder = number % denominator;
-        return bigIntToNumber(quotient) + (bigIntToNumber(remainder) / 
bigIntToNumber(denominator));
+        const remainder = negative? -(number % denominator) : number % 
denominator;
+        const integerPart = bigIntToNumber(quotient);
+        const fractionPart = padStart((remainder).toString(), scale);

Review Comment:
   Minor suggestion, but we should be able to use the String built-in and 
remove the `padStart` below this:
   
   ```suggestion
           const fractionPart = `${remainder}`.padStart(scale, '0');
   ```



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