Ticket #2036 (closed defect: fixed)
CPLAtof() - different results than atof()
| Reported by: | warmerdam | Owned by: | mloskot |
|---|---|---|---|
| Priority: | high | Milestone: | 1.5.2 |
| Component: | OGR_SRS | Version: | svn-trunk |
| Severity: | major | Keywords: | CPLAtof |
| Cc: | dron, mloskot, msieczka, neteler, warmedam |
Description
The following precision different between atof() and CPLAtof() is having annoying "knock on" affects on generation of EPSG definition files.
warmerda@amd64[45]% cat test1.cpp
#include "gdal.h"
#include "cpl_conv.h"
int main()
{
double x1, x2;
const char *str = "6356566.435";
x1 = atof(str);
x2 = CPLAtof(str);
printf( "%.16g, %.16g\n", x1, x2 );
}
warmerda@amd64[46]% ./test1
6356566.435, 6356566.435000001
(gdb) run
Starting program: /wrk/home/warmerda/test1
[Thread debugging using libthread_db enabled]
[New Thread 46912564802784 (LWP 354)]
[Switching to Thread 46912564802784 (LWP 354)]
Breakpoint 1, main () at test1.cpp:8
8 const char *str = "6356566.435";
(gdb) n
10 x1 = atof(str);
(gdb)
11 x2 = CPLAtof(str);
(gdb)
13 printf( "%.16g, %.16g\n", x1, x2 );
(gdb) p x1
$1 = 6356566.4349999996
(gdb) p x2
$2 = 6356566.4350000005
Change History
Note: See
TracTickets for help on using
tickets.
