[Proj] Re: Re: Proj4 Bug (rtodms)

cp ch.panel at free.fr
Wed Nov 8 09:10:09 PST 2006


After these rights observations, I look at more seriously this portion of 
code.

The numbers have effectively right and exact representations in ten-bytes 
format, but the compiler instead of making r/60 makes r * 1/60 so it changes 
a little thing. I precise that this is done without any optimization (force 
no optimization) and with option "don't correct FDIV flaw" (for old 
processors) and "no quick floating points". I have seen some quircks in 
MS-Compiler, now I am seeing in Borland compiler.

It is not possible to go through and to force the compiler (I don't know how 
?) to generate fdiv instead of fmul instruction.

here is the code generated

   ;
   ;   res1 = (int)(r / 60.);
   ;
 ?debug L 11
 fld       tbyte ptr [@2]                                     <= 1/60 with 8 
bytes precision and not 10 bytes precision
 fmul      qword ptr [ebp-8]
 call      __ftol
 mov       dword ptr [_res1],eax
   ;
   ;   res2 = floor(r / 60.);
   ;
 ?debug L 12
 fld       tbyte ptr [@2]
 fmul      qword ptr [ebp-8]
 add       esp,-8
 fstp      qword ptr [esp]
 call      _floor
 add       esp,8
 call      __ftol
 mov       dword ptr [_res2],eax
   ;
   ;   printf("%s",(res1==res2) ? "OK!" : "NOT OK!");


A different code is generated by MS-Compiler which is right in this case.

A same Code is generated with the free command line compiler BCC32.exe : 
Borland C++ 5.5.1 (Borland Builder, disabling too all optimizations)

So the problem is staying for all people who are working with Borland 
environment or with code optimization and  r / 60. give a false result.


In Last, thanks for all constructors of proj4 and BRAVO for the work 
accomplished.

C.PANEL







More information about the Proj mailing list