Hello Ben, in the video, at 2:58, you say this:
When you initialize a floating point value,
you need to put and f after the number so that it turns this thing into a float.
If you just say 10, you may get an error that says I’m not sure what this number is
or it may treat it as a double.
but if you write, i.e,
float f = 10;
you don’t need to put f
because there is always an implicit conversion between an int (10) and a float.
The problem is if you write something like:
float f2 = 10.4;
In this case there is no implicit conversion between a double (10.4) and a float and therefore you have a compilation error.
So if you only write 10, you don’t have a mistake in your case.You are not required, as you say, to specify that it is a float with the suffix f
. You are not required, as you say, to specify that it is a float with the suffix f
.
Moreover, 10
, as you still say, can never be seen as a double
; it will always be just an int
(to be precise, a System.Int32
type).
It would be the case of an adjustment to avoid misunderstandings especially for those who are new to C#.
Thanks.