- Home /
float precision, again
Hi, my first post here, yey!!
i read all i could find about floats, doubles, conversion, precision, but couldn't find anything to help me. so here goes...
i have this code:
var myvar : float = 0.0;
print("value:" + myvar + " really?"+Mathf.Approximately(myvar, 0.0));
expected result? myvar should be 0.0, approximately should be true. instead, myvar is 0.00xxxxxx and approximately evaluates to false. i have tried to floor it, round it, floor( myvar * 1000) / 1000, all i could remember, myvar is never zero.zero
how can i assign a float a simple value (0.0 1.0 etc) and have it evaluate to exactly that value?
works for me
var x : float = 0.0;
Debug.Log(x + " approximately zero? " + $$anonymous$$athf.Approximately(x, 0.0) );
shows "0 approximately zero? True"
what have you done to your poor computer
right, it doesn't add up. even broken .dlls have crossed my $$anonymous$$d.but it seems there's always some lack of precision. another thing that is failing me is (Time.deltatime - Time.deltatime) == 0.0
i've tried other programs to see if i could get the same problem, but they return proper results. how much more weird can it get?
Your answer
Follow this Question
Related Questions
Comparing float value to zero 1 Answer
Show 1 decimal only when printing a float 1 Answer
Mathf.Lerp not working as expected 2 Answers
Convert double to float for Vector3 1 Answer