- Home /
How can a Property show one set of values while the Member variables show another?
I'm getting a weird bug whilst accessing a Vector3's x,y,z parameters where the inspector is showing one set of values whilst the member variables themselves are displaying an entirely different set of values.
Is this a known bug? or is this a designed behaviour. Either way I need some advice as I have no idea on where to even start correcting this kind of problem as direct assignment seems to make little difference.
/storage/temp/17873-inconsistantparameters.png
Answer by Dracorat · Nov 13, 2013 at 05:35 PM
Hello, Float Imprecision coupled with rounding!
but surely by 'Flooring' a value the binary bits would be exact, or am I missing the point?
Not in floating numbers. In decimal numbers, sure. Floating numbers are stored internally using fractions and you can't get precise numbers with fractions. The link has more info.
You will get whole numbers - which I see you did in your code, but the inspector wasn't on yPos. It was on the Vector3.
Learn something new everyday, Thanks. So I should cast to something more precise before comparing?
Actually you should allow for small variances... if(a - b < .001 && a - b > -.001) /*For all purposes, equal*/