I have read in many places, to the point that it’s literally the only statement you will find, that the Atari systems used BCD for their math. But someone just posted a reply in a very old thread on SO that makes me wonder if that is entirely accurate.
The post was about the TI-99, which used Radix 100 for math. I had never heard this term before, and the brief bit I found about it seems to suggest that the difference is basically that the numbers are stored not as two digits of base 10, but in essence, a single byte-long value in base 100.
But I recall in a previous thread on the Atari that it too did everything in 100’s, but I did not (and still don’t) really understand these things, so I did not follow up on that.
So can those that do understand this: is the Atari really Radix 100 as well? And what, practically, is the difference?
A manual might tell us, or failing that, a disassembly. Quick searches indicate that TI were the only ones to venture into Radix 100.
One possible benefit of Radix 100 is that it has room for a sign bit, if needed. A disadvantage is that exponents are powers of 100, so you lose a decimal digit’s worth of mantissa half the time. (I think IBM’s early floating point had a similar weakness, where exponents were powers of 16.)
A possible advantage of Radix 100… maybe performance? Certainly in a CPU without a BCD mode. And I’m not sure about multiplication, in the two cases of BCD and Radix 100 - they are both more tricky than shift-and-add which we usually use for binary.
But this is just me riffing - not a citation in sight!
I’m almost 100% sure that the Atari’s BASIC used BCD, rather than Radix-100. Exhibit A is ATR: chpt.11: Floating Point Package, which describes the floating point format as:
Floating point number representation
byte 0 xx excess 64 exponent + sign
xx \
xx \
xx > 10 BCD digits
xx /
byte 7 xx /
It stores 10 BCD digits in five bytes. I’m not sure how it stores the bytes, but I’m going to assume it’s hex 00 to hex 99, with gaps at 0a…0f, 1a … 1f, etc.
Had it used Radix-100, it could still hold 10 digits in five bytes, but each byte would hold 00 … 99 (decimal) with no gaps.
I tried to mess about with Atari BASIC to see if I could print values stored in the FR0 and FR1 float buffers, but I was clearly doing something wrong, as they never changed. As I know 0 about Atari BASIC, I am unsurprised
Looks to me like a typo in the original: should be byte 5, for a 6 byte float. Just possibly there was some capability for 8 byte floats, but the buffers are described as 6 bytes.
I did a project where I worked heavily with the Atari’s floating-point routines, and I can say for sure they were BCD. Each floating-point number was encoded in 6 bytes. The first byte contained a kind of “metadata,” with sign info., and the exponent. I think the other 5 bytes just contained the float data. Each byte contained two digits from 0 to 9, each digit in a nibble. Ironically, the best way to view this data was in hexadecimal, because if you tried to view it in decimal, you wouldn’t see the decimal digits encoded in the bytes that clearly. The Atari’s float calculation routines used the 6502’s decimal mode. However, outside of that, the 6502 was used in its native binary mode for things like calculating addresses. If you programmed in Atari Basic, all numeric values (except for line numbers) were stored in BCD, since all numeric values were stored as floats. However, if you programmed in assembly, you typically used integers for numeric values, and in that case, you could work in radix 10. Though, hex was typical. You could work in BCD using the 6502’s decimal mode, but that was optional. There are languages on the Atari that work with integers, and in that case, it’s radix 10.
It turns out that there are many, many ways of encoding decimal in bytes and words, and entire careers at IBM have been dedicated to finding the most efficient ones. One of those careers belonged to Mike Cowlishaw (aka the Rexx guy), who documented the General Decimal Arithmetic website and came up with the Densely packed decimal (DPD) encoding.