Status: Tags: #aCards/cmpt295/binary Links: Binary
Binary rounding rules
Principles
- Worth of a bit is the value of 2x where x is associated with its position in the bit pattern, even though the bit itself may be 0
Types
Identify bit at rounding position, and determine rounding type:
Round up
?
- sum of bits to right > half of rounding bit
- ex) if rounding pos is worth 1/4, check if left is greater than 1/8
- ex) 0110 is round up
- Add 1 to the bit at rounding position, discard bits to the right
Round down
?
- sum of bits to right < half of rounding bit
- ex) 0011 is round down
- DIscard bits
Round to even number
?
- If bits to right == bit at rounding
- ex) 001 is round to even
- round such that the bit at the rounding position becomes 0
- If the bit at rounding position is 1 => then we round to even number by rounding up
- Add 1 to left of position bit
- if the bit at rounding position is already 0 => then we round to even number by rounding down
Rounding IEEE
- Positioned bit is 23rd bit
Examples
Backlinks
|
|
References:
Created:: 2022-01-24 14:47