Re: printf() on decimals
- Posted by Greg Haberek <g.haberek at comcast.net> Jun 30, 2003
- 607 views
> Try this: > > printf(1, "%.16g\n", 1999999999999990) > printf(1, "%.16g\n", 2999999999999990) > printf(1, "%.16g\n", 3999999999999990) > printf(1, "%.16g\n", 4999999999999990) > printf(1, "%.16g\n", 5999999999999990) > printf(1, "%.16g\n", 6999999999999990) > printf(1, "%.16g\n", 7999999999999990) > printf(1, "%.16g\n", 8999999999999990) > printf(1, "%.16g\n", 9999999999999990) > > > Why is the last line printed differently? ex.exe produced: 1999999999999990 2999999999999990 3999999999999990 4999999999999990 5999999999999990 6999999999999990 7999999999999990 8999999999999990 9999999999999990 however, exw.exe produced: 1999999999999990 2999999999999990 3999999999999990 4999999999999990 5999999999999990 6999999999999990 7999999999999990 8999999999999990 9.99999999999999e+015 i assume this has to do with how windows handles floating-point math as opposed to dos and 'nix.