0
just a question on the Get That Discount! puzzle in c#
so in the solution i see: if (i <= 10000) i = (int)(i*0.8f) return i; what does the "f" after the 0.8 do? and also my code was: if (i <= 10000) { i = (int)(i - 0.2*i) return i; (like the explanation part says: (i - 0.2*i))
2 Answers
+ 1
The "f" after the 0.8 tells the compiler that you're entering a float value. Without it, C# will interpret the numbers as double, which can't be automatically converted to either a float or decimal.
+ 1
The reason for the f after 0.8 is because it's a float number (another Data Type than Double).