Binary ExpansionΒΆ

All rational numbers have repeating binary expansions. Operations to access the individual bits of a binary expansion can be obtained by converting the value to RadixExpansion(2).

The expansion (of type BinaryExpansion) of a rational number is returned by the binary operation.

r := binary(22/7)
    ___
 11.001
                    Type: BinaryExpansion

Arithmetic is exact.

r + binary(6/7)
 100
                    Type: BinaryExpansion

The period of the expansion can be short or long.

[binary(1/i) for i in 102..106]
    ________
 [0.00000101,
    ___________________________________________________
  0.000000100111110001000101100101111001110010010101001,
       ____________    ____________
  0.000000100111011, 0.000000100111,
     ____________________________________________________
  0.00000010011010100100001110011111011001010110111100011]
                    Type: List BinaryExpansion

or very long.

binary(1/1007)
   ________________________________________________________________________
 0.000000000100000100010100100101111000001111110000101111110010110001111101
   ________________________________________________________________________
   000100111001001100110001100100101010111101101001100000000110000110011110
   ________________________________________________________________________
   111000110100010111101001000111101100001010111011100111010101110011001010
   ________________________________________________________________________
   010111000000011100011110010000001001001001101110010101001110100011011101
   ________________________________________________________________________
   101011100010010000011001011011000000101100101111100010100000101010101101
   ________________________________________________________________________
   011000001101101110100101011111110101110101001100100001010011011000100110
   ____________________________________
   001000100001000011000111010011110001
                    Type: BinaryExpansion

These numbers are bona fide algebraic objects.

p := binary(1/4)*x**2 + binary(2/3)*x + binary(4/9)
             __       ______
 0.01 x^2 +0.10 x + 0.011100
                    Type: Polynomial BinaryExpansion

q := D(p, x)
           __
 0.1 x + 0.10
                    Type: Polynomial BinaryExpansion

g := gcd(p, q)
     __
 x+1.01
                    Type: Polynomial BinaryExpansion

See Also:

  • )help DecimalExpansion
  • )help HexadecimalExpansion
  • )show BinaryExpansion

Table Of Contents

This Page