Convert From Dec To Bin #223
sergey-shandar
started this conversation in
Ideas
Replies: 5 comments
if 53 bits left if 53 bits left |
0 replies
const s = "0.1"
// [1, -1]
let [dM, dE] = parse(s)
// increase Matnisa to 53 bits.
while (dM < 2 ** 53) {
dM *= 10
dE -= 1;
}
// |
0 replies
|
Another presentation of if In result we have Task: |
0 replies
|
|
0 replies
// a / b
// Make sure `min * b <= a < max * b` by multiplying/dividing `a` by `r` and decreasing/increasing `e`, where `min` is a minimal mantissa value.
const mantissa = uRoundDiv(a)(b) |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
How to divide big floats
Unsigned BigInt Rounding
Convert From One Base To Another
Our floating point number is represented as$m*r^e$ .
Any$m*base^e$ can be converted to a fraction of two unsigned integers.
if$e >= 0$ then $\frac{mr^e}{1}$ else $\frac{m}{r ^{-e}}$
As a result, we have$a / b$ , where
Converting a fraction to a floating point number
Assume$a <= b$
Find$m$ and $e$ where $b <= r^e < br$
where$r^n <= m < r^{n+1}$
All reactions