Why is there sometimes an f behinf a number?

Hello, I’m following a few different tutorials on unity and scripting and i noticed that some put an f behind an integer or float when they are assigning it to a variable and I was wondering what the use of it is and why some people place an f and some don’t.

Both Unityscript and C# use “f” to indicate a float and “d” to indicate a double. The difference is that double is the default for C#, but float is the default for Unityscript. So if you use a decimal number but leave off the “f” or “d”, then it will use the default for whatever language you’re using.

The ‘f’ is needed in C# because it has two different types of floating point numbers: float and double. C#'s default floating point type is double, but everything in Unity is a float, so the f is needed to force the compiler to treat a number like 3.286 as a float instead of a double.

The f is for a floating point number in C#. So you are seeing it in C#, and not in uJS. Make sure you know the difference between the two. Here’s some links I found useful in converting between C# and JS. Read the first one especially, as they will explain the differences :

unifycommunity.com?

http://fragileearthstudios.com/2011/10/18/unity-converting-between-c-and-javascript-2/

Edit : decided that I would leave the ‘double’ explanation to a C# person =]