I tried doing the following:
float a = 10.5;
//compile error (required float, provided double)
Meaning the default decimal is always double
, which is 64-bit long, whereas float
is 32-bit long. So technically I can't put something big in a smaller 'cup'.
Then I did some corrections, that both work. I am curious what is the difference (if there is any) between these two approaches:
float a = 10.5f;
float a = (float)10.5;