Aug 28, 2015 Replies: 4 It may happen sometimes that, if your dealing with complex non-integer calculations, your code may not perform exactly the way you want to. I came across this problem when I was trying so create a solar system simulation, my Earth wouldn't achieve a stable orbit until I replaced all the FLOAT variables by DOUBLES. I'm guessing it's way more precise. Erel might enlighten us on this. EDIT: I think I've found the answer: http://www.java-samples.com/showtutorial.php?tutorialid=261 Float is 32bit while Double is 64bit. If we learned anything from the 90's is that more bits = more power!! Code: 'Before Dim EarthMass = 5.972 * Power(10, 24) As Float 'in KG Code: 'After Dim EarthMass = 5.972 * Power(10, 24) As Double 'in KG Last edited: Aug 28, 2015 Click to expand...
It may happen sometimes that, if your dealing with complex non-integer calculations, your code may not perform exactly the way you want to. I came across this problem when I was trying so create a solar system simulation, my Earth wouldn't achieve a stable orbit until I replaced all the FLOAT variables by DOUBLES. I'm guessing it's way more precise. Erel might enlighten us on this. EDIT: I think I've found the answer: http://www.java-samples.com/showtutorial.php?tutorialid=261 Float is 32bit while Double is 64bit. If we learned anything from the 90's is that more bits = more power!! Code: 'Before Dim EarthMass = 5.972 * Power(10, 24) As Float 'in KG Code: 'After Dim EarthMass = 5.972 * Power(10, 24) As Double 'in KG
klaus Expert Licensed User Longtime User Aug 28, 2015 #2 For me, using Float variables to do calculations is 'none sense' because you loose a lot of accuracy with almost no memory trouble.
For me, using Float variables to do calculations is 'none sense' because you loose a lot of accuracy with almost no memory trouble.
wonder Expert Licensed User Longtime User Aug 28, 2015 #3 klaus said: For me, using Float variables to do calculations is 'none sense' because you loose a lot of accuracy with almost no memory trouble. Click to expand... A lesson I should have learned one year ago...
klaus said: For me, using Float variables to do calculations is 'none sense' because you loose a lot of accuracy with almost no memory trouble. Click to expand... A lesson I should have learned one year ago...
wonder Expert Licensed User Longtime User Aug 28, 2015 #5 Ctrl + F Find: As Float Replace with: As Double 643 entries found. Done.