Forum Discussion

R0bot's avatar
R0bot
Copper Contributor
Oct 06, 2024

[Question 1][Clarification on "Fixed Fractional Values" in C# Float Data Type Usage]

Hi,

 

Reffering to this lesson in C#:

 

"Notice that the float data type is the least precise, so it's best to use this data type for fixed fractional values to avoid unexpected computation errors."

 

Could you please clarify what exactly is meant by "fixed fractional values" in this context ? An example would also be appreciated.

 

Thank you !

  • Floating point calculations can be imprecise. Fixed Fractions are numbers such as 1/2, 3/4, 7/8 etc which have only a limited number of decimal places. Floating point data type uses less bytes than a decimal and when memory is a premium, this matters.
  • Floating point calculations can be imprecise. Fixed Fractions are numbers such as 1/2, 3/4, 7/8 etc which have only a limited number of decimal places. Floating point data type uses less bytes than a decimal and when memory is a premium, this matters.

Resources