[Proj] Re: Proj4 Bug (rtodms)
ch.panel at free.fr
Wed Nov 8 04:29:25 EST 2006
first, excuse me for my poor english.
"Gerald I. Evenden" <gerald.evenden at verizon.mail> a écrit dans le message de
news: 200611051448.17043.gerald.evenden at verizon.mail...
> So far, I have not found any way to reproduce your problem and
> find no reason to change code. However, I do have a couple of questions:
this simple program produce a "NOT OK" output :
static int res1,res2;
res1 = r / 60.;
res2 = floor(r / 60.);
printf("%s",(res1==res2) ? "OK!" : "NOT OK!");
I think that because floor corrects values that were epsilon under the
absolute value, if epsilon is smaller than the floating point precision.
my compiler is Borland C++ compiler and I work on Windows XP, but I don't
think that C runtime libraries at this point are differents ??? (I believe
not because of portability with Kylix) ???
> 1. on what hardware (chip) was this problem created,
> 2. what compiler/library was employed and
Borland C (CW3230mt.dll)
> 3, level of optimization specified.
> Interestingly, r before being divided by 60 does not have a fractional
> component (exactly equal to 240.). The implication is that the floating
> point processor produces a "ragged" result where the mantissa is not
> rational. That is, something like 3.9999... is produced. The floor
> operation should still have produced 3 as the unchanged code did with
> conversion to integer with the memory assignment of the division
> I suspect something is gummed up with the handling of the extra bits that
> part of the mantissa in the floating point hardware.
I don't, but the hardware in the FPU works with 10 bytes instead of 8
because of precision and exact numbers doesn't exist in FPU
> Lastly, the problem line has been handle by:
> deg = (int)(r / 60.);
the problem cannot be resolved by this
> for some time in the libproj4 library. The cast was necessary to keep the
> compiler from complaining during -Wall runs.
> Lastly, rtodms is deprecated and will be replaced with rad2dms which
> for greater format flexibility and is (unlike rtodms) thread proof.
> The whole religious complexion of the modern world is due
> to the absence from Jerusalem of a lunatic asylum.
> -- Havelock Ellis (1859-1939) British psychologist
> Proj mailing list
> Proj at lists.maptools.org
More information about the Proj