[Coco] printing out floating point numbers...(only peripherally related to coco)
Aaron Banerjee
spam_proof at worldnet.att.net
Tue Jul 11 19:49:42 EDT 2006
All,
I'm working on a program that can handle floating point numbers with
gobs and gobs of precision. I'd like to make a float similar to the IEEE
754 standard (1 sign bit, 8 exponent bits, and 23 precision bits), but of
much more precision. What's more I'd like to be able to do basic
arithmetic with these high-precision floats (e.g. +, - , /, *) quickly,
even on a slow processor. This sounds like something someone has at least
tried to do at one time on a coco.
The form of a float I happen to be using is a 32 byte value:
bit 0: sign (S)
bits 1-8: exponent (E)
bits 9-255: precision (F)
where the final value is:
value = (-1)^S * 2^(E-127) * 1.F
Of course, you realize that using regular floats and doubles to evaluate
the above expression would kill off all of the wonderful precision I was
looking for in the first place. Has anyone ever done anything of the
sort? How did you solve it (e.g. C++ class? Assembly?)
On another note, given such a float, I'm trying to get a good routine to
print them to the screen (or a string).
This actually sounds like something that would be in a textbook somewhere,
but I don't seem to be able to find it. Thanks in advance for your help.
- Aaron
More information about the Coco
mailing list