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))

14th Jul 2022, 7:03 PM
devmonke 🇨🇦
devmonke 🇨🇦 - avatar
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.
14th Jul 2022, 7:15 PM
Abdelrahim Mohamed Alsadiq
Abdelrahim Mohamed Alsadiq - avatar
+ 1
The reason for the f after 0.8 is because it's a float number (another Data Type than Double).
14th Jul 2022, 7:12 PM
Felix Alcor
Felix Alcor - avatar