what does 1.e-004 mean ?
Blitz3D Forums/Blitz3D Beginners Area/what does 1.e-004 mean ?
| ||
Hello, When i debug the values of the vertices normals of a surface, i get the values ""1.e-004", what does this mean ? Apparently the normals direction are correct, but i want to get a value between 0.000 and 1.000, not this weirdness Thanks, |
| ||
If i'm not wrong it's an exponent, so it would be equal to Sometimes blitz return this kind of value, probably linked to max numbers after the decimal point, rounded numbers or float accuracy. |
| ||
Yeah it's an exponential form. 1.0 x 10 ^ (0-4) This is not usually an issue and will function correctly EXCEPT In cases such as: n% = Int(f#) where f# = Float#("1.e-004") n SHOULD equate to 0 as the closest integer, but instead takes the '4' digit and returns 4 instead. To prevent this, given you have a set range for your FP accuracy, multiply first: BiggerInt=Int(Floor(f#*10000.0)) Which will resolve the float into an integer to the accuracy specified. Then divide back into a more appropriate float: Divided#=Float(BiggerInt*0.0001) |
| ||
here are 2 others weird value, this time positions : 2.56409e-004 -7.05128e-004 so basically, this means that when the float value is too small, it returns a kind of string with infos about the small float values ? 2.56409e-004 would be 0.000256409 -7.05128e-004 would be -0.000705128 correct ? |
| ||
Try this :a# = 0.001 : DebugLog a a = 0.00123456789 : DebugLog a DebugLog "" a = 0.0001 : DebugLog a a = 0.000123456789 : DebugLog a DebugLog "" a = 0.0000000001 : DebugLog a a = 0.000000000123456789 : DebugLog a WaitKey End It returns an exponential form when you have 0.000X or more zero after the decimal point, in order to be able to keep very small values. |
| ||
I see... Thanks. |
| ||
It's just a different way to express th nsame number similar to standard form 1.0 e4 = 10000 1.0 e-4 = 0.0001 The size of tne number is largely irrelevant, any number can be written in this form - it is more convenient for arithmetic of many such numbers though. 6.0e-12 / 2.0e-4 = 3.0e-8 ____ 1^-4 = 0.0001 This is wrong. 1^-4 = the reciprocal of quartic 1 / (1^4) = 1 You misrepresented the exponent as requiring the base of 10 : 1 * (10 ^ (0-4)) = 0.0001 |
| ||
Yes you're right _PJ_, I've never been good in mathematics... |
| ||
It's the "scientific" way to write floats. You 'll find the same with large numbers (4.1245e30 for example which would be a 41245 followed by a tons of zeros) To make it simple, if the right value is negative (the part after the "e") : take the left part then multiply by 0.1 X times (X is the value after the "e") ex : 1.234 e -5 1.234 * 0.1 * 0.1 * 0.1 * 0.1 * 0.1 If the right part is positive, then do the same but multiply by 10 instead of 0.1 so in your example : 2.56409e-004 = 2.56409 * 10^-4 -> 2.56409 * 0.0001 = 0.000256709 |
| ||
Because floats are not precise you should usually use a tolerance value to capture such things. If the float abs value is smaller than a tolerance assume it is zero. Back in a uni maths class i had in 1996 we were advised that when dealing with computers this was the case. |