On Mar 7, 6:17 am, Pavel <dot_com_yahoo@paultolk_reverse.yourself>
wrote:
James Kanze wrote:
I did not want to write myself and was looking for a library
because I am lazy and some corner cases should be worked out
(native representation does not necessarily represent all same
set of numbers as IEEE 754 representations).
If you have to deal with a native representation that is not
IEEE, then you have to define behavior for corner cases. An IBM
double, for example, has more precision (but less range) than an
IEEE double: I suppose when outputting you round (the code I
posted truncates!), but what happens when you input something
that it too large.
I've heard that there may be similar cases even between IEEE
representations, at least where NaN's are involved---a non
trapping NaN may trap elsewhere, or something like that.
It's quite a bit of coding and testing so I wanted to find if
someone else has already done that before getting into it. I
guess I will start with this code of yours and then try to
work my way using standard C++. Certainly #ifdef - guarded
multi-platform version would do faster for each supported
architecture but hopefully the performance of the standard C++
code will suffice for my purpose.
Well, I'd very definitely not invest the effort in supporting
machines without IEEE until I had to. (The three I know of
today are all mainframes: one uses base 16, one uses base 8, and
the one that uses base 2 has 72 bit doubles. On the latter two,
you'll need special handling for ints as well, because they
don't use 2's complement either: there's one with 48 bit signed
magnitude, with 8 bits required to be 0, and the other uses 36
bit 1's complement. Porting networked software to those should
be quite amusing---except that both have Intel based front-ends
to handle the networking.)
--
James Kanze (GABI Software) email:ja*********@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34