Debug.Log(2000.0f * 000.1f);
Someone help me out here.
Why is that.
Debug.Log(2000.0f * 000.1f);
Someone help me out here.
Why is that.
0.1 is 10%. What were you expecting?
lol yeah. sorry I misread/missed the misplaced decimal point: XD more coffee required
Now that you have had your coffee, don’t forget about floating point imprecision:
// @kurtdekker: don't forget about floating point imprecision
using UnityEngine;
public class FloatingPointImprecision : MonoBehaviour
{
void Start ()
{
float a = 2000.0f;
float b = 0.1f;
float product = (a * b);
float answer = 200;
Debug.Log( "a = " + a);
Debug.Log( "b = " + b);
Debug.Log( "product of a*b = " + product);
Debug.Log( "answer = " + answer);
Debug.Log( "does product equal answer? " + (product == answer));
Debug.Log( "does a*b equal answer? " + ((a * b) == answer));
}
}
Your mileage almost certainly will vary. Choose an epsilon term and know it well.
It’s posts like this that make me glad I do Stupid mistakes.
I would <3 this twice if I could