J
jameskuyper
kerravon said:That's inconsistent with (among many other things) the maximum values
for FLT_EPSILON and DBL_EPSILON specified in 5.2.4.2.2p11.
Ok. Another alternative. Is there anything preventing float
and double being defined as say
typedef struct {
char decimal[100];
} double;
It can't literally be a typedef for a struct, at least not as seen by
user code. A conforming compiler must diagnose code like the
following, for instance:
double d = {"decimal string"};
d.decimal[4] = 'a';
However, a conforming implementation could, in the internals of
functions which implement floating point operations, treat double as
if it were store in a way that is equivalent to the above typedef.
and then implemented as a really crappy C library, but
taking the burden off the compiler, while still meeting
C90 requirements?
That would be possible, depending upon how the char array were used,
which is something you haven't specified. I suspect that you intend to
use it to store a string representation of the floating point number
similar to what sprintf() could create with the appropriate format
specifiers (making implementation of that particular specifier for
sprint() trivial). Before you decide to take that route, I would
recommend looking at section 5.2.4.2.2 very carefully, as well as well
as 7.7 (<float.h>) and 7.12 (<math.h>). I think that, in the end,
you'll find that the easiest way to meet those requirements on a
machine without an FPU is to emulate an FPU in software. Storing
numbers in string format won't make the task easier, it will make it
harder.