How to normalize a mantissa

后端 未结 5 1647
你的背包
你的背包 2020-12-09 05:15

I\'m trying to convert an int into a custom float, in which the user specifies the amount of bits reserved for the exp and mantissa, but I don\'t understand how

5条回答
  •  情歌与酒
    2020-12-09 06:03

    To normalize a mantissa you place the decimal point to the left of the leftmost non-zero digit

    for example

    represent 10.11 base 2 in normalize form

    = 0.1011 base 2 * 2 to the second power

    the base of two is because you are working with binary numbers and the power of +ve 2 is because you moved the decimal point left two times. Remember that only 4 bits are used for the mantizza

    so the mantizza would be 1011

提交回复
热议问题