From 0d1444766d49b11105b729c7564f47e7d1557946 Mon Sep 17 00:00:00 2001 From: maybellineboon Date: Thu, 14 Sep 2023 17:38:17 -0700 Subject: [PATCH 1/2] update decoder.js .decoder__bucket--decimal and .decoder__value--decimal Updating the .decoder__bucket--decimal and .decoder__value--decimal to use BigInt instead of using parseInt. parseInt has a maximum of 52 bits and anything beyond 52 bits does not convert very well. Bucket keys have a maximum of 128 bits and using just BigInt with a binary signature will help convert the binary correctly. --- sites/home/decoder/decoder.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sites/home/decoder/decoder.js b/sites/home/decoder/decoder.js index 63c70c8..7f69da8 100644 --- a/sites/home/decoder/decoder.js +++ b/sites/home/decoder/decoder.js @@ -19,9 +19,9 @@ const ZEROES_FOR_PADDING = '00000000'; function renderOutput({ bucketInBinary, valueInBinary }) { document.querySelector('.decoder__bucket--binary').innerHTML = bucketInBinary; - document.querySelector('.decoder__bucket--decimal').innerHTML = BigInt(parseInt(bucketInBinary, 2)); + document.querySelector('.decoder__bucket--decimal').innerHTML = BigInt("0b" + bucketInBinary); document.querySelector('.decoder__value--binary').innerHTML = valueInBinary; - document.querySelector('.decoder__value--decimal').innerHTML = BigInt(parseInt(valueInBinary, 2)); + document.querySelector('.decoder__value--decimal').innerHTML = BigInt("0b" + valueInBinary); } // Converts the number to a binary string From e696d0907b244d14b3fa67a4a1f8d8efd9381e7e Mon Sep 17 00:00:00 2001 From: "Kevin K. Lee" Date: Fri, 15 Sep 2023 08:32:40 -0400 Subject: [PATCH 2/2] Update decoder.js --- sites/home/decoder/decoder.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sites/home/decoder/decoder.js b/sites/home/decoder/decoder.js index 7f69da8..c5a0064 100644 --- a/sites/home/decoder/decoder.js +++ b/sites/home/decoder/decoder.js @@ -19,9 +19,9 @@ const ZEROES_FOR_PADDING = '00000000'; function renderOutput({ bucketInBinary, valueInBinary }) { document.querySelector('.decoder__bucket--binary').innerHTML = bucketInBinary; - document.querySelector('.decoder__bucket--decimal').innerHTML = BigInt("0b" + bucketInBinary); + document.querySelector('.decoder__bucket--decimal').innerHTML = BigInt(`0b${bucketInBinary}`); document.querySelector('.decoder__value--binary').innerHTML = valueInBinary; - document.querySelector('.decoder__value--decimal').innerHTML = BigInt("0b" + valueInBinary); + document.querySelector('.decoder__value--decimal').innerHTML = BigInt(`0b${valueInBinary}`); } // Converts the number to a binary string