skip to Main Content

We Know in Javascript it uses the STD IEEE 754 Double precision and we know that the Mantissa Section is 52 bit and there is implicit 1 bit but is not stored

But if it isn’t stored how it’s actually we represent it because we can store 52 bit that 1 bit what we are using for ?

2

Answers


  1. In JavaScript, as in many programming languages that use the IEEE-754 double-precision floating-point standard, the 53rd bit (the implicit bit) is part of the representation of the mantissa or significand but is not physically stored.

    You need to know two different intervals in the range of representable floating-point numbers.

    1.Normalized

    2.subnormal or denormal

    (Normalized)

    In the IEEE-754 representation, if the exponent is non-zero, the number is considered normalized. In this case, the leading bit of the mantissa is implicitly 1.

    This means that, while only 52 bits are stored in the mantissa field, the computer treats the number as if the mantissa is 53 bits, with the first bit being 1.

    (Subnormal)

    When the exponent is 0, the number is treated as subnormal (denormalized). In this case, the leading bit is 0 instead of 1.

    For subnormal numbers, the full precision is reduced slightly because there’s no implicit leading 1, and the number is represented directly using the 52 bits of the mantissa without a leading 1.

    Subnormal is used to represent the value ranges between -1 to 0 to 1.

    (How the Computer Decodes)

    Exponent field: The computer first checks the exponent field. If it is zero, the number is subnormal, and the leading bit is 0. If the exponent is non-zero, the number is normalized, and the leading bit is assumed to be 1.

    Mantissa field: The 52-bit mantissa field is combined with the implicit leading bit (either 1 for normalized or 0 for subnormal) to form the full mantissa.

    Why it this done?

    This trick here is used to gain one more bit of precision without needing extra storage space. Since normalized numbers always have a leading 1 in their binary representation, storing it would be redundant.

    Login or Signup to reply.
  2. The leading bit of the significand is said to be “implicit,” but that is misleading. The leading bit is encoded in the bits that represent the floating-point field. It is in the “exponent” field, which actually encodes several things. Taking the eight bits of the “exponent” field as a binary numeral E:

    • If E = 2047, the bits represent an infinity or a NaN (depending on the bits in the trailing significand field).
    • If 0 < E < 2047, the bits represent an exponent of E−1023 and a leading significand bit of 1.
    • If E = 0, the bits represent an exponent of −1022 and a leading significand bit of 0.

    So the leading bit is not implicit; it is an explicit function of the “exponent” field.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search