Some of you may be interested in Sinclair’s 5-byte floating point binary representation, if for no other reason than knowing how they do it. The following procedure demonstrates conversion of decimal numbers to floating point binary. For example, convert 325 decimal to floating point:
1) Convert the decimal number to binary: 325 = 101000101
2) The number of binary bits plus 128 equals the first floating point byte, the exponent byte:
number of bits = 9; 9+128 = 137
3) Set the most significant bit (MSB) to 0 and divide the number into nibbles (4 bits = 1 nibble), filling in 0s at the least significant byte (LSB) position to complete any partial nibble:
001000101 = 0010 0010 1000
4) Convert each nibble to hexadecimal and then convert the hex to decimal, filling in 0s as needed to complete conversion to hexadecimal (remember, you need two nibbles to make one hex number):
0010 0010 1000 0000 = 22 80 hex
= 34 128 dec.
5) Add 0s to make 5 bytes:
325 decimal = 137 34 128 0 0 in Sinclair floating point.
Convert 6524:
1) 6524 = 1100101111100 2) 13 bits, 13+128 = 141 (exponent) 3) 1100 1011 1110 0000 4) 22 80 hex, 75 224 decimal 5) 6524 = 141 75 224 0 0
(This method works only for positive integers.–EO)