Evaluating in Dolphin Transcript
1.0 / 10 returns 0.100000001490116 Does anyone knows why?, I remember some time ago I where working in the definition of the core classes for a new Smalltalk and I had a similar same problem. It seems like an Intel problem or something like that, correct me if I wrong. It's hard to beleive that my cpu doesn't know how to divide. Diego |
Diego,
> Evaluating in Dolphin Transcript > > 1.0 / 10 > > returns > > 0.100000001490116 > > Does anyone knows why?, [] > It's hard to beleive that my cpu > doesn't know how to divide. It's because some decimal numbers cannot be exactly converted into binary so all floating point operations must be thought of as approximate. This happens on all computers and in all languages, the only variable is how much precision you can get before the differences become noticeable. In this case though I think you may also have a problem with your image. Evaluating 1.0 / 10 gives me the expected result of 0.1. How were you performing the test. -- Ian Use the Reply-To address to contact me. Mail sent to the From address is ignored. |
Diego, Ian,
> In this case though I think you may also have a problem with your image. > Evaluating 1.0 / 10 gives me the expected result of 0.1. I can reproduce this by using CRTLibrary>>_controllfp:mask: to set the floating point "unit" to use 24 bit precision, and can correct it by setting the precision back to 64bit. Since I don't actually know what the hell I'm playing at with this stuff, I won't post example code ;-) However, Dolphin doesn't seem to save and restore most of the floating point control word (only the FP Exception mask) with the image so I guess that the problem will cure itself at the next restart. (I'd still make a backup, just in case...) Dolphin only really exposes the ability to modify the FP settings in the very lowest-level of ways, and I imagine that it's unlikely that you've changed it by accident. It is possible that there is some badly-behaved third party DLL that you are calling from Dolphin that is changing the settings and failing to put them back. -- chris |
Chris,
This seems to be exaclty the problem. This behavior occurs after I load an ActiveX control (a 3D engine), if I restart Dolphin everything works fine again. I will spend some time this weekend studing how to fix it, trying to bring back Float precision to 64 bits, currently I have no idea. Thanks Chris and Ian. Diego |
Diego,
> This seems to be exaclty the problem. This behavior occurs after I load an > ActiveX control (a 3D engine), if I restart Dolphin everything works fine > again. > I will spend some time this weekend studing how to fix it, trying to bring > back Float precision to 64 bits, currently I have no idea. I wouldn't want you to waste too much of your valuable weekend ;-). Here's more detail of what I was doing, but please remember that I /do not/ know what I'm doing with this stuff, so this is just to help speed up your researches, rather than knowledgeable advice on how to fix the problem. The FP control mask is set by the _controlfp() function in the C library. You'll be able to find more information in MSDN, I imagine. To turn 24bit mode /on/: CRTLibrary default _controlfp: 16r20000 mask: 16r30000. And to switch back to 64bit mode: CRTLibrary default _controlfp: 16r00000 mask: 16r30000. If you talk to the developers of the ActiveX control about the problem, then they'll probably understand the equivalent C code better: _controlfp(_PC_24, _MCW_PC); or: _controlfp(_PC_64, _MCW_PC); Just for interest, what control is it ? HTH -- chris |
Thank you Chris, your solution works great. I don't know why too, like most
things I do. The ActiveX control is Wild Tangent, a 3D engine. If you are interesting in taking a look at that I have uploaded a Goodie some time ago at: http://www.smalltalking.net/Goodies/Dolphin/index.htm |
Diego,
> The ActiveX control is Wild Tangent, a 3D engine. If you are interesting > in taking a look at that I have uploaded a Goodie some time ago at: > > http://www.smalltalking.net/Goodies/Dolphin/index.htm Thank you. I took a look around the Web and newsgroups for "Wild Tangent", and I did /not/ like what I found, so I think I'll be staying away from their software... -- chris |
Free forum by Nabble | Edit this page |