[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: problems with large values of doubles
> From: Prabhat Avasare <firstname.lastname@example.org>
> Date: Fri, 2 Feb 2001 18:08:05 +0100 (MET)
> I am having some very basic problems with double
> data type. Consider the following program --
> double d1 = 9999999999999999.1;
> double d2 = 9999999999977777.1;
> // double d1 = 9999.9999999999991;
> // double d2 = 9777.9999999777771;
> d1 = 2147483647, d2 = 2147483647, i1 = 0
> d1 = 10000, d2 = 9778, i1 = 222
> Is there any problem with doubles on Etrax?
Before the latest compiler tools release, the type "double" was
the same as "float" -- a 32-bit type, so what you are seeing is
the expected overflow.
Since programmers are rarely aware (QED) of the fact that
"double" is *not* always a 64-bit type (or bigger), this has
been changed. Note that an implementation with a 32-bit double
is still correct, as long as a "float" does not have higher
precision or "long double" does not have less precision.
> Am I
> linking a wrong C library?
No, I think this is not the problem.
> I had asked a similar
> question related to fmod() before, but didnt get
> any reply.
I'm sorry about that; somebody should have got back to you. I
guess (but have not investigated) that the problem then was that
the uclibc library does not have a proper fmod prototype, so the
arguments were passed as ints. Somebody else might know for
> In a similar note, why are doubles disabled in
> printfs? How can I print large doubles(greater
> than MAX_INT) then?
Not "disabled" just the same as "float". You could try "long
double", but then you'd only have normal arithmetic, no math
functions and presumably %ld isn't supported in uclibc printf.
> I am using Axis 2400 camera server board with 1.0.2
> release of software(including cris-dist-1.7).
I suggest an upgrade to cris-dist-1.11 if "double" being 64 bit
is important for your application. Note that you then need a
patch for devboard-1.0.2 - see developer.axis.com.