Conversion to Binary and IEEE-754 Binary
|
06-29-2020, 01:33 PM
Post: #3
|
|||
|
|||
RE: Conversion to Binary and IEEE-754 Binary
(06-27-2020 01:35 PM)Eddie W. Shore Wrote: Bit 1 is the sign bit: 1 for negative numbers, 0 for positive numbers Another interpretation is to think of exponents field and the mantissa overlapped on the imply bit. For IEEE single, instead of bias of 127, do offset 126 Example: x = 2100 = 1.025390625 * 2^11 = 0b1.000001101 * 2^(0b10001001 - 126) Code: sign = 0 This has the advantage of extending conversion to sub-normal, without special treatment. (i.e. when mantissa cannot converted to pattern 1.xxx ..., with bexp already reached 0) Example: x = 1e-40f ≈ 71362.38 / 2^149. Since 71362 < 2^24, bexp = 0 → bits = 71362 = 0b 00000000 00000001 00010110 11000010 gcc:1> unsigned u = 71362 gcc:2> G(*(float*) &u) 9.9999461011147596e-041 gcc:3> G(1e-40f) /* confirm */ 9.9999461011147596e-041 |
|||
« Next Oldest | Next Newest »
|
Messages In This Thread |
Conversion to Binary and IEEE-754 Binary - Eddie W. Shore - 06-27-2020, 01:35 PM
RE: Conversion to Binary and IEEE-754 Binary - Albert Chan - 06-27-2020, 08:37 PM
RE: Conversion to Binary and IEEE-754 Binary - Albert Chan - 06-29-2020 01:33 PM
RE: Conversion to Binary and IEEE-754 Binary - Eddie W. Shore - 06-29-2020, 01:58 PM
RE: Conversion to Binary and IEEE-754 Binary - Eddie W. Shore - 08-02-2020, 02:51 PM
|
User(s) browsing this thread: 1 Guest(s)