This is the mail archive of the cygwin@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

atof returns a value that is slightly greater than the originalstring


Hello Cygwinners,

I'm having some strange problems with atof. basically, it returns a
converted value that is 0.000024 bigger than the one on the string.

Google searching suggested that the problem was to do with #include
<stdlib.h>, but I already have that #include in my program and I still
get strange results. A program like this:

#include <cstdlib>
#include <iostream>

int main (void)
{
float f = atof ("695.40");

cout << f;
}

compiles and outpus nicelly:

$ ./main
695.4

but if i debug it, its actually not correct:

(gdb) b 6
Breakpoint 1 at 0x80485f6: file main.cpp, line 6.
(gdb) r
Starting program: /home/phase/work/src/a.out 

Breakpoint 1, main () at main.cpp:6
(gdb) p f
$1 = 3.99009619e-34     ----> before assignment
(gdb) n
(gdb) p f
$2 = 695.400024         ----> after assignment
(gdb) 

since I need this the data to generate a sum, the sum ends up a bit off
because of this. and unfortunatelly, because there is so many people
with the #include problem, its impossible to search the web properly.
I'm sure its something i'm doing (or not doing), just can't see what...

A cygcheck is attached. 

Many thanks for your time.

marco.

Cygnus Win95/NT Configuration Diagnostics
Current System Time: Mon Sep 10 21:13:08 2001

Win95 Ver 4.0 build 67109814 

Path:	/usr/local/bin
	/usr/bin
	/bin
	/cygdrive/c/ELJ-WIN32/SMALLEIFFEL/BIN
	/cygdrive/c/ELJ-WIN32/LCC/BIN
	/cygdrive/c/WINDOWS
	/cygdrive/c/WINDOWS/COMMAND
	/BIN

SysDir: C:\WINDOWS\SYSTEM
WinDir: C:\WINDOWS

PWD = `/home/phase'
USER = `gbcrav01'
MAKE_MODE = `unix'
HOME = `/home/phase'

Use `-r' to scan registry

a:  fd           N/A    N/A                    
c:  hd  FAT     2047Mb  60% CP    UN           
d:  cd  CDFS     573Mb 100% CP                 NEW

c:\cygwin  /        user    textmode

Found: c:\cygwin\bin\bash.exe
Found: c:\cygwin\bin\cat.exe
Found: c:\cygwin\bin\cpp.exe
Found: c:\cygwin\bin\find.exe
Found: c:\WINDOWS\COMMAND\find.exe
Found: c:\cygwin\bin\gcc.exe
Found: c:\cygwin\bin\gdb.exe
Found: c:\cygwin\bin\ld.exe
Found: c:\cygwin\bin\ls.exe
Found: c:\cygwin\bin\make.exe
Found: c:\ELJ-WIN32\LCC\BIN\make.exe
Found: c:\cygwin\bin\sh.exe

   56k 2000/12/03 c:\cygwin\bin\cygbz21.0.dll
   45k 2000/12/07 c:\cygwin\bin\cygform5.dll
   18k 2000/10/23 c:\cygwin\bin\cyggdbm.dll
   17k 2000/11/30 c:\cygwin\bin\cyghistory4.dll
   14k 2000/10/23 c:\cygwin\bin\cygintl.dll
   81k 2000/12/05 c:\cygwin\bin\cygitcl30.dll
   35k 2000/12/05 c:\cygwin\bin\cygitk30.dll
   45k 2000/10/22 c:\cygwin\bin\cygjbig1.dll
  119k 2000/10/22 c:\cygwin\bin\cygjpeg6b.dll
   26k 2000/12/07 c:\cygwin\bin\cygmenu5.dll
  159k 2000/12/07 c:\cygwin\bin\cygncurses++5.dll
  225k 2000/12/07 c:\cygwin\bin\cygncurses5.dll
   15k 2000/12/07 c:\cygwin\bin\cygpanel5.dll
  162k 2000/10/22 c:\cygwin\bin\cygpng2.dll
  108k 2000/11/30 c:\cygwin\bin\cygreadline4.dll
  390k 2000/12/05 c:\cygwin\bin\cygtcl80.dll
    5k 2000/12/05 c:\cygwin\bin\cygtclpip80.dll
   10k 2000/12/05 c:\cygwin\bin\cygtclreg80.dll
  243k 2000/10/22 c:\cygwin\bin\cygtiff3.dll
  623k 2000/12/05 c:\cygwin\bin\cygtk80.dll
   41k 2000/11/20 c:\cygwin\bin\cygXpm-noX4.dll
   45k 2000/11/20 c:\cygwin\bin\cygXpm-X4.dll
   49k 2000/10/22 c:\cygwin\bin\cygz.dll
  611k 2000/12/25 c:\cygwin\bin\cygwin1.dll
    Cygwin DLL version info:
        dll major: 1001
        dll minor: 7
        dll epoch: 19
        dll bad signal mask: 19005
        dll old termios: 5
        dll malloc env: 28
        api major: 0
        api minor: 31
        shared data: 3
        dll identifier: cygwin1
        mount registry: 2
        cygnus registry name: Cygnus Solutions
        cygwin registry name: Cygwin
        program options name: Program Options
        cygwin mount registry name: mounts v2
        cygdrive flags: cygdrive flags
        cygdrive prefix: cygdrive prefix
        cygdrive default prefix: 
        build date: Mon Dec 25 12:39:48 EST 2000
        shared id: cygwin1S3

Use -h to see help about each section

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]