Background: I am reading "How Numbers Work" in the book How JavaScript Works by Douglas Crockford.
A number in JavaScript is represented as number = sign * coefficient * (2 ** exponent)
. I understand this but then there is a function deconstruct
to represent an integer using the sign
, coefficient
, and exponent
.
In order to find the exponent
, the initial value is taken as -1128
which is the exponent of 'Number.MIN_VALUE' minus the number of bits in the significand minus the bonus bit.
function deconstruct(number) {
// .....
exponent = -1128;
let reduction = coefficient;
while (reduction !== 0) {
// .....
}
Why is exponent = -1128
? I did not get the reason for starting with this number, please help me in understanding this.
The complete deconstruct function as mentioned in the book.
A similar question is asked here but I did not understand the answer.