Real Number

浮点数:不确定位数

Fixed-point representation

  1. al overall number of bits is chosen
  2. with a defined number of bits for the whole number part
  3. and the remainder for the fractional part
  • The binary point is set in a fixed position and it does not need to be stored in the memory
  • Special attention needs to be paid to be position/ place values of those bits after the binary point

Floating point representation

  1. The form: Mantissa x 2^exponent
  2. examples

Precision

Remember we have to decide:

  1. the total number of bits used.
  2. the number of bits used for matissa
  3. the number of bits used for exponent.

Note:

  1. 前后两个部分都是two’s compliment,前面表示整数部分,后面是exponential
  2. mantissa表示精度,exponent表示范围, mantissa分到的数位越多,所表示的数字越精确;exponential的数位越多,所表示的数字范围越大
  1. A binary representation is only an approximation of a real number.
  2. Increasing the number of bits for mantissa gives a better precision
  3. But leaves less number of bits for exponent, which reduces the range of numbers can be represented

Where should the point be?

When the mantissa has the implied binary point immediately following the sign bit, a smaller spacing is produced between the values that can be represented.

  • Example: Totally 8 bits are used: 4 for mantissa and 4 for exponent. The total number of numbers that can be represented is 2^8 = 256

Normalization:

What if 8 bits are used, 4 for mantissa, 4 for exponent? Normalization is to achieve maximum precision by using all the bits fully. Normalization:

For a positive number, the bits in the mantissa are shifted left until the most significant bits are 0 followed by 1. For a negative number, the bits in the mantissa are shifted left until the most significant bits are 1 followed by 0.

Move to normalize form: 左侧不能出现连续的0。可将整体移位:

  1. 小数点向右移动n位
  2. 在小数点后exponential 部分binary number 减去n

Conversion of representations

2 → 10:

  • Normalized floating-point number. 0100011 0100
  • Mantissa: 0100011 →2425+26
  • Exponent 0100 →4
  • (242+25)X2 = 2+2+22=8.75

10 → 2

  • Positive: 8.75
  • 8 → 01000, remember to add an 0.
  • 75 7 11
  • 8.75 → 01000.11
  • 8.75 → 0.100011 0100
  • 8.75 → 0100011000 0100

yellow 10 bits for mantissa and 4 bits for exponent

Conversion of repersentations

暂无评论

发送评论 编辑评论


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇
下一篇