Can someone tell me for what is the f in 0.0f ?
For example:
// Disable screen dimming
Screen.sleepTimeout = 0.0f;
And are there some other letters used with numbers?
Thanks!
Can someone tell me for what is the f in 0.0f ?
For example:
// Disable screen dimming
Screen.sleepTimeout = 0.0f;
And are there some other letters used with numbers?
Thanks!
It’s explicitly casting it as a floating point number, as opposed to an int
Indeed the ‘f’ indicates that you want a float. If you write a fractional number without the suffix, you get a double-precision number by default, which you don’t want. So you just always use the suffix.
0 is an int
0f is a float
0.0 is a double
0.0f is a float
Aah, didn’t realise 0.0 was cast as a double, live and learn
Thank you very much for your answers!
I dont understand what you mean with “double”?
What is the difference between double and float?
A double uses double the bits of a float (64 vs 32 bit) and is therefor slower to calculate but in return is generally much more precise and covers a larger range of numbers.
http://msdn.microsoft.com/en-us/library/b1e65aza(v=vs.71).aspx
http://msdn.microsoft.com/en-us/library/678hzkk9(v=vs.71).aspx