A Floating Point Problem
deSilva
Posts: 2,967
I successfully ran FloatDemo using (the slow) FloatMath and FloatString.
I then changed "FloatMath" to "Float32" in FloatDemo.
This worked well, but FloatString still used FloatMath
I then changed "FloatMath" to "Float32" in FloatString as well.
Bingo!
I debugged for half an hour without success - what can be the problem??
It seems that FloatString.Setup() never returns (endless repeat loop)...
I then changed "FloatMath" to "Float32" in FloatDemo.
This worked well, but FloatString still used FloatMath
I then changed "FloatMath" to "Float32" in FloatString as well.
Bingo!
I debugged for half an hour without success - what can be the problem??
It seems that FloatString.Setup() never returns (endless repeat loop)...
Comments
No, Math32 works fine, but MathString does not!
I have a FloatingPoint program that was using Float32 AND FloatString.
FloatString on the other hand uses FloatMath, which is inefficient and useless memory spending, so I changed the OBJ in FloatString also to "Math32".
This however did not work!
It was not clear to me in the beginning, but the entry of
F : "Float32"
in OBJ - of course! - instantiates a new copy of Float32!
But how can you avoid this???? I want FloatString to use the same instance of Float32 as the main program. I have found nothing in the Spin manual to allow this!
The work around was - of course - to copy FloatString into Main, but this is awkward and not at all modular.
Any ideas?
Post Edited (deSilva) : 6/24/2007 8:45:07 PM GMT
Post Edited (Mike Green) : 6/24/2007 8:08:46 PM GMT
Careful design of moduls can help, as Mike pointed out: In this special case it seems that the culprits were the object variables "command" and "cmdReturn" which should rather have been (static) class variables in the data section. Maybe I can provide a fix but I will first make some changes to Math 32, allowing for parallel work on small vectors and complex numbers as well as keeping an unpacked format for chain calculations.
You probably guessed it: The Mandelbrot Set, but is is still so slow......