Content deleted Content added
Prepended a missing "1" onto the list of decode bit values to correct an error in the explanation of how to decode a token. |
No edit summary |
||
Line 33:
To encode an integer ''X'':
#
#
# Working downward from the ''Nth'' bit to the first one, compare each of the corresponding negaFibonacci numbers to the remainder. Subtract it from the remainder if the absolute value of the difference is closer to zero, AND if the next higher bit does not already have a one in it. A one is placed in the appropriate bit if the subtraction is made, or a zero if not.
#
To decode a token in the code, remove the last "1", assign the remaining bits the values 1,-1,2,-3,5,-8,13... (the [[negafibonacci]] numbers), and add the "1" bits.
|