From: Ben R. <Ben...@sc...> - 2010-06-04 10:52:02
|
There is something very wrong somewhere because if you are performing x / 640.0 * 9e-6 For 0.0 <= x <= 640.0 Your results should be way less than 1. For x = 640 the result is 9e-6 and for anything else it is less. I tried int value; for(value = 100; value < 120; value ++) { std::cout << value << ": " << (double(value)/640.0*9e-6) << std::endl; } and got 100: 1.40625e-006 101: 1.42031e-006 102: 1.43438e-006 Using >g++ --version g++ (GCC) 4.4.0 Copyright (C) 2009 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. >From the mingw project. What you are getting is more than a truncation error, the result is not even in the right ball park I would want to see further evidence before I started questioning the compiler. -----Original Message----- From: Richard C. Wagner [mailto:drsavage@q.com] Sent: 04 June 2010 01:38 To: MinGW Users Subject: [Mingw-users] MinGW and Floating Point Hi All: Has anyone here made much use of MinGW with scientific or floating point calculations? I've written a Mandelbrot generator, and I'm seeing truncation errors at values far above where I expect them. Specifically, I'm taking an integer pixel coordinate from 0 to 640, converting it to a floating point number, dividing it by a floating point 640, and multiplying that result by another small float, in this case, 9.0e-6. And the answer doesn't change with each increment of the first number. I've written a stand-alone test program doing just this calculation and here are the results: Pixel_x = 100 Domain_x = 1.00000143051147460000 Pixel_x = 101 Domain_x = 1.00000143051147460000 Pixel_x = 102 Domain_x = 1.00000143051147460000 Pixel_x = 103 Domain_x = 1.00000143051147460000 Pixel_x = 104 Domain_x = 1.00000143051147460000 Pixel_x = 105 Domain_x = 1.00000143051147460000 Pixel_x = 106 Domain_x = 1.00000154972076420000 Pixel_x = 107 Domain_x = 1.00000154972076420000 Pixel_x = 108 Domain_x = 1.00000154972076420000 Pixel_x = 109 Domain_x = 1.00000154972076420000 Pixel_x = 110 Domain_x = 1.00000154972076420000 Pixel_x = 111 Domain_x = 1.00000154972076420000 Pixel_x = 112 Domain_x = 1.00000154972076420000 Pixel_x = 113 Domain_x = 1.00000154972076420000 Pixel_x = 114 Domain_x = 1.00000154972076420000 Pixel_x = 115 Domain_x = 1.00000166893005370000 Pixel_x = 116 Domain_x = 1.00000166893005370000 Pixel_x = 117 Domain_x = 1.00000166893005370000 Pixel_x = 118 Domain_x = 1.00000166893005370000 Pixel_x = 119 Domain_x = 1.00000166893005370000 If you're interested, I can post the code. These results are far grainier, numerically, than they hardware can provide. Does anyone understand what's going on? Rich Wagner ------------------------------------------------------------------------ ------ ThinkGeek and WIRED's GeekDad team up for the Ultimate GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the lucky parental unit. See the prize list and enter to win: http://p.sf.net/sfu/thinkgeek-promo _______________________________________________ MinGW-users mailing list Min...@li... This list observes the Etiquette found at http://www.mingw.org/Mailing_Lists. We ask that you be polite and do the same. Disregard for the list etiquette may cause your account to be moderated. _______________________________________________ You may change your MinGW Account Options or unsubscribe at: https://lists.sourceforge.net/lists/listinfo/mingw-users SciSys UK Limited. Registered in England and Wales No. 4373530. Registered Office: Methuen Park, Chippenham, Wiltshire SN14 0GB, UK. * Before printing, please think about the environment. |