When I write a Vector3 value to the console, the values will be rounded to the nearest decimal (e.g., (0.7, 0.1, 0.0)) but in reality, if I access just that single x value, it’s actually something like 0.666879345.
Is the console just multiplying the actual vector by ten, rounding to int, then dividing by ten? Otherwise, I’m curious if there some way to access that already rounded value myself…
I do not understand, why is it not reliable? It will always cover the range of all float values in the range of ].65f, .75f[ in this case. (not including the numbers .65 and .75 themselves.
As i understand the question he is looking for a way to round the float without converting it to int prior. So I do not think your point is valid as this is a valid method for the rounding. Performing calculations with floating point numbers is a different issue. :)
that is a general problem in computing (see Wikipedia on Floating Point Values). the computer cannot ‘really’ display a 0.7, instead he saves that the number as something like 0.666879345.
Therefore I don’t think what you want is possible and a problem of the represantation of floating values in general.
Interesting link… Although I think I might have explained poorly what I was asking. I don't want the full float, I just want to use the same number being displayed in the console. var figure = Vector3(0, 0.599999, 0); Debug.Log(figure); would show as 0.0, 0.6, 0.0 in the console. But if I try… if (figure.y == 0.6) Debug.Log("hello!"); ...It won't work. :)
Wow, I must admit I do not understand why a 0.1 can not be represented by a binary number. Since it is 1e-1 and both 1 and -1 can be represented by binary numbers. If you put a 0.7 in a float variable, the debugger will always show it to be 0.7 as long as you do no arithmetic with it. Which confuses me even further. I think I will have to do some reading on the topic soon, so thanks for the discussion. :D
Well, I guess technically that would work though, in a roundabout sort of way. ;)
– Eric5h5