Binary number: Difference between revisions

Content deleted Content added
moving a section referring to binary arithmetic after the section of that name
Line 199:
 
:'''100101<sub>2</sub> = 37<sub>10</sub>'''
 
==Fractions==
 
In binary arithmetic, the binary expansion of a [[fraction]] [[Repeating decimal|terminates]] only if the [[denominator]] is a [[power of 2]]. As a result, 1/10 does not have a finite binary representation (10 has prime factors 2 and 5). This causes 10 × 1/10 not to precisely equal 1 in binary [[floating-point arithmetic]]. As an example, to the binary expansion of 1/3 is .010101..., which means that
:<math>\frac 13 = 0 \times 2^{-1} + 1 \times 2^{-2} + 0 \times 2^{-3} + 1 \times 2^{-4} + \cdots.</math>
An exact value cannot be found with a sum of a finite number of inverse powers of two, the zeros and ones in the binary representation of 1/3 alternate forever.
 
{| class="wikitable"
|-
! Fraction
! [[Base 10|Decimal]]
! Binary
! Fractional approximation
|-
| 1/1
| 1{{pad|0.25em}}or{{pad|0.25em}}0.999...
| 1{{pad|0.25em}}or{{pad|0.25em}}0.{{Overline|1}}
| 1/2 + 1/4 + 1/8...
|-
| 1/2
| 0.5{{pad|0.25em}}or{{pad|0.25em}}0.4999...
| 0.1{{pad|0.25em}}or{{pad|0.25em}}0.0{{Overline|1}}
| 1/4 + 1/8 + 1/16 . . .
|-
| 1/3
| 0.333...
| 0.{{Overline|01}}
| 1/4 + 1/16 + 1/64 . . .
|-
| 1/4
| 0.25{{pad|0.25em}}or{{pad|0.25em}}0.24999...
| 0.01{{pad|0.25em}}or{{pad|0.25em}}0.00{{Overline|1}}
| 1/8 + 1/16 + 1/32 . . .
|-
| 1/5
| 0.2{{pad|0.25em}}or{{pad|0.25em}}0.1999...
| 0.{{Overline|0011}}
| 1/8 + 1/16 + 1/128 . . .
|-
| 1/6
| 0.1666...
| 0.0{{Overline|01}}
| 1/8 + 1/32 + 1/128 . . .
|-
| 1/7
| 0.142857142857...
| 0.{{Overline|001}}
| 1/8 + 1/64 + 1/512 . . .
|-
| 1/8
| 0.125{{pad|0.25em}}or{{pad|0.25em}}0.124999...
| 0.001{{pad|0.25em}}or{{pad|0.25em}}0.000{{Overline|1}}
| 1/16 + 1/32 + 1/64 . . .
|-
| 1/9
| 0.111...
| 0.{{Overline|000111}}
| 1/16 + 1/32 + 1/64 . . .
|-
| 1/10
| 0.1{{pad|0.25em}}or{{pad|0.25em}}0.0999...
| 0.0{{Overline|0011}}
| 1/16 + 1/32 + 1/256 . . .
|-
| 1/11
| 0.090909...
| 0.{{Overline|0001011101}}
| 1/16 + 1/64 + 1/128 . . .
|-
| 1/12
| 0.08333...
| 0.00{{Overline|01}}
| 1/16 + 1/64 + 1/256 . . .
|-
| 1/13
| 0.076923076923...
| 0.{{Overline|000100111011}}
| 1/16 + 1/128 + 1/256 . . .
|-
| 1/14
| 0.0714285714285...
| 0.0{{Overline|001}}
| 1/16 + 1/128 + 1/1024 . . .
|-
| 1/15
| 0.0666...
| 0.{{Overline|0001}}
| 1/16 + 1/256 . . .
|-
| 1/16
| 0.0625{{pad|0.25em}}or{{pad|0.25em}}0.0624999...
| 0.0001{{pad|0.25em}}or{{pad|0.25em}}0.0000{{Overline|1}}
| 1/32 + 1/64 + 1/128 . . .
|}
 
==Binary arithmetic==
Line 494 ⟶ 400:
110, so next digit of next digit of answer is 1.
answer is 0.
 
==Fractions==
 
In binary arithmetic, the binary expansion of a [[fraction]] [[Repeating decimal|terminates]] only if the [[denominator]] is a [[power of 2]]. As a result, 1/10 does not have a finite binary representation (10 has prime factors 2 and 5). This causes 10 × 1/10 not to precisely equal 1 in binary [[floating-point arithmetic]]. As an example, to the binary expansion of 1/3 is .010101..., which means that
:<math>\frac 13 = 0 \times 2^{-1} + 1 \times 2^{-2} + 0 \times 2^{-3} + 1 \times 2^{-4} + \cdots.</math>
An exact value cannot be found with a sum of a finite number of inverse powers of two, the zeros and ones in the binary representation of 1/3 alternate forever.
 
{| class="wikitable"
|-
! Fraction
! [[Base 10|Decimal]]
! Binary
! Fractional approximation
|-
| 1/1
| 1{{pad|0.25em}}or{{pad|0.25em}}0.999...
| 1{{pad|0.25em}}or{{pad|0.25em}}0.{{Overline|1}}
| 1/2 + 1/4 + 1/8...
|-
| 1/2
| 0.5{{pad|0.25em}}or{{pad|0.25em}}0.4999...
| 0.1{{pad|0.25em}}or{{pad|0.25em}}0.0{{Overline|1}}
| 1/4 + 1/8 + 1/16 . . .
|-
| 1/3
| 0.333...
| 0.{{Overline|01}}
| 1/4 + 1/16 + 1/64 . . .
|-
| 1/4
| 0.25{{pad|0.25em}}or{{pad|0.25em}}0.24999...
| 0.01{{pad|0.25em}}or{{pad|0.25em}}0.00{{Overline|1}}
| 1/8 + 1/16 + 1/32 . . .
|-
| 1/5
| 0.2{{pad|0.25em}}or{{pad|0.25em}}0.1999...
| 0.{{Overline|0011}}
| 1/8 + 1/16 + 1/128 . . .
|-
| 1/6
| 0.1666...
| 0.0{{Overline|01}}
| 1/8 + 1/32 + 1/128 . . .
|-
| 1/7
| 0.142857142857...
| 0.{{Overline|001}}
| 1/8 + 1/64 + 1/512 . . .
|-
| 1/8
| 0.125{{pad|0.25em}}or{{pad|0.25em}}0.124999...
| 0.001{{pad|0.25em}}or{{pad|0.25em}}0.000{{Overline|1}}
| 1/16 + 1/32 + 1/64 . . .
|-
| 1/9
| 0.111...
| 0.{{Overline|000111}}
| 1/16 + 1/32 + 1/64 . . .
|-
| 1/10
| 0.1{{pad|0.25em}}or{{pad|0.25em}}0.0999...
| 0.0{{Overline|0011}}
| 1/16 + 1/32 + 1/256 . . .
|-
| 1/11
| 0.090909...
| 0.{{Overline|0001011101}}
| 1/16 + 1/64 + 1/128 . . .
|-
| 1/12
| 0.08333...
| 0.00{{Overline|01}}
| 1/16 + 1/64 + 1/256 . . .
|-
| 1/13
| 0.076923076923...
| 0.{{Overline|000100111011}}
| 1/16 + 1/128 + 1/256 . . .
|-
| 1/14
| 0.0714285714285...
| 0.0{{Overline|001}}
| 1/16 + 1/128 + 1/1024 . . .
|-
| 1/15
| 0.0666...
| 0.{{Overline|0001}}
| 1/16 + 1/256 . . .
|-
| 1/16
| 0.0625{{pad|0.25em}}or{{pad|0.25em}}0.0624999...
| 0.0001{{pad|0.25em}}or{{pad|0.25em}}0.0000{{Overline|1}}
| 1/32 + 1/64 + 1/128 . . .
|}
 
==Bitwise operations==