Hello
I'm having some trouble understanding the following behavior: If I substract two doubles: (12345.678d) - (12345.677d) the result is 0.0010000000002037d Shouldn't the result be 0.001d? Am I missing something? |
i think that's the usual problem with doubles and floats:
http://en.wikipedia.org/wiki/Floating_point#Accuracy_problems Kind Regards Karsten Am 18.08.10 08:15, schrieb habo: > Hello > > I'm having some trouble understanding the following behavior: > > If I substract two doubles: > (12345.678d) - (12345.677d) > the result is > 0.0010000000002037d > > Shouldn't the result be 0.001d? > > Am I missing something? > -- Karsten Kusche - Dipl. Inf. - [hidden email] Georg Heeg eK - Köthen Handelsregister: Amtsgericht Dortmund A 12812 _______________________________________________ vwnc mailing list [hidden email] http://lists.cs.uiuc.edu/mailman/listinfo/vwnc |
In reply to this post by habo
Perhaps what you're looking for is, _______________________________________________ vwnc mailing list [hidden email] http://lists.cs.uiuc.edu/mailman/listinfo/vwnc |
Thank you for a quick answer.
I'm not sure I can use a FixedPoint because of the nature of the software, but I will check. On the other hand maybe I can just "hide" the problem by using a print method with a correct printPolicy... Regards Habo |
In reply to this post by habo
Some decimal fractions with a finite representation are periodical in
binary numeral system. As Double has limited precision these numbers cannot be represented completely. E.g. your numbers are 12345.678d = 12345.677734375 12345.677d = 12345.6767578125 0.001d = 0.0010000000474974513 Additionally some rounding errors occur during calculation with floating point numbers (float, double). It's very likely that these two effects lead to your result. Regards, Steffen Am 18.08.2010, 08:15 Uhr, schrieb habo <[hidden email]>: > > Hello > > I'm having some trouble understanding the following behavior: > > If I substract two doubles: > (12345.678d) - (12345.677d) > the result is > 0.0010000000002037d > > Shouldn't the result be 0.001d? > > Am I missing something? vwnc mailing list [hidden email] http://lists.cs.uiuc.edu/mailman/listinfo/vwnc |
In reply to this post by habo
Another possibility would be using Fraction for all internal calculations.
They do not suffer from side effects like floating points. Steffen Am 18.08.2010, 08:48 Uhr, schrieb habo <[hidden email]>: > > Thank you for a quick answer. > > I'm not sure I can use a FixedPoint because of the nature of the > software, > but I will check. > On the other hand maybe I can just "hide" the problem by using a print > method with a correct printPolicy... > > Regards > Habo vwnc mailing list [hidden email] http://lists.cs.uiuc.edu/mailman/listinfo/vwnc |
Hi All,
We have an application that implements a visual programming environment to simulate and analyze radiographs. We started to use the JUN package to create our objects. On the Windows XP boxes it works fine, we can create an object, view it, calculate the pathlengths of the rays passing through the object. However Linux 64bit is another story, I changed the libraries the JunMesaInterface was looking for to the 64 bit versions of theX11 libraries. Now I can create the object and it displays once; If I change the Viewfinder window size, close and reopen the viewfinder, the object isn't there. Is there something else I have to change to get the JUN package to work on a 64 bit Linux machine? (I using Red Hat Linux.) Thanks _______________________________________________ vwnc mailing list [hidden email] http://lists.cs.uiuc.edu/mailman/listinfo/vwnc |
I'm converting my application to run in headless mode and have a comment
and question or two.
From the AppDevGuide.pdf, page 20-2 HeadlessImage default startupFilename: nil If you do not want to use a startup file, evaluate the following expression: Shouldn't these two line be reversed? Question 1, Is it possible to tell the system that the startup file will have a different name each run? Question 2, Do you need to specify the startup name on the command line? I believe that if you declare a startup file name for the headless image, then you don't have to specify the name on the command line _______________________________________________ vwnc mailing list [hidden email] http://lists.cs.uiuc.edu/mailman/listinfo/vwnc |
At 12:13 PM 2010-10-27, Jim Harsh wrote:
I'm converting my application to run in headless mode and have a comment and question or two.If you do not want to use a startup file, evaluate the following expression: Shouldn't these two line be reversed? Yes. Question 1, Is it possible to tell the system that the startup file will have a different name each run? You can specify it on the command line with -hlstrc startupFilename.st I think it would be possible, but rather tricky, to have it be different each time in a way not specified from the command line. You'd need some piece of code to run in a subsystem that ran earlier than HeadlessImage (Load "Tools-Startup Ordering Tool" to get a browser tab that will show you the startup order when a subsystem is selected. The tricky bit is what that code would do to figure out what to change it to, and how it would make it different each time without doing something like reading from the command line. Question 2, Do you need to specify the startup name on the command line? No, there's a default of "headless-startup.st" I believe that if you declare a startup file name for the headless image, then you don't have to specify the name on the command line Yes. _______________________________________________ --
Alan Knight [|], Engineering Manager, Cincom Smalltalk
_______________________________________________ vwnc mailing list [hidden email] http://lists.cs.uiuc.edu/mailman/listinfo/vwnc |
Thanks Alan, I found my problem; JUN was trying to "ScheduleControllers restore" the headless image didn't like. I commented that line out and it's now working. In the transcript the system writes out the AvailableFreeOldSpace and AvailableFreeFixedSpace mixed with some out put I'm causing. Anyway to suppress the Avail.... messges or to force a wait for my routines to avoid the mixing of the messages. This is what the first couple of lines of the transcript file looks like. AvailableFreeOldSpaceBytes: Filing in from:52,109,412 3:17:17 PM AvailableFreeFixedSpaceBytes: GeometricObjectParameter204,800 -> GeometricObjectParameter 401,372ConvertToUniformGrid2D ConvertToUniformGrid2D from here on it looks as expect it to look. Thanks, jim At 01:23 PM 10/27/2010, Alan Knight wrote: At 12:13 PM 2010-10-27, Jim Harsh wrote: _______________________________________________ vwnc mailing list [hidden email] http://lists.cs.uiuc.edu/mailman/listinfo/vwnc |
Free forum by Nabble | Edit this page |