P Witte wrote:
While were talking fp, can someone please explain what the purpose of the $81f bias (or whatever the technical term) is? Why not just represent exponents as +/-32k ?
Per
It's a bit "historic", I suspect.
It allows all operations on the exponent to be done with unsigned arithmetic, which saves some brain work when implementing the stuff.
It gives an easy test for a "magic" value of zero exponent, which is handy for the "special" cases. If is were not biased, you would have to use a value like "0x8000", which would become messy.
The specific bias varies, but to some extent is one that preserves a balance of mantissa precision for maximum and minimum absolute values. It is generally just one off what you'd expect.
Note that, with the IEEE format, operations on both exponent and mantissa are unsigned (as it uses a separate flag to indicate positive/negative value). The QDOS implementation is somewhat of a hybrid, as it uses signed arithmetic for the mantissa. I suspect Sinclair adopted that format to make the code a fraction quicker. By doing so (instead of using the "concealed leading bit"), you lose one bit of precision (and introduce the "invalid representation" problems), but you can write shorter, more straightforward software code. The IEEE format is expected to be done by harware, which can happily "re-manifest" the concealed leading bit of the fly. I'm waffling a bit here... but if QL used a concealed leading one on a 32-bit mantissa, it would have to do 33-bit arithmetic all the time.
PS. Just as an aside, I cut my teeth on IBM System/360 floating point, which used a hexadecimal exponent! Very ragged precision - not a good idea at all!
--
Lau
http://www.bergbland.info
Get a domain from http://oneandone.co.uk/xml/init?k_id=5165217 and I'll get the commission!
