Mare Infinitus Mare Infinitus - 1 year ago 119
C# Question

Precision of double after decimal point

In the lunch break we started debating about the precision of the

value type.

My colleague thinks, it always has 15 places after the decimal point.

In my opinion one can't tell, because IEEE 754 does not make assumptions
about this and it depends on where the first
is in the binary
representation. (i.e. the size of the number before the decimal point counts, too)

How can one make a more qualified statement?

Answer Source

As stated by the C# reference, the precision is from 15 to 16 digits (depending on the decimal values represented). Precision meaning the number of decimal digits a value can hold (regardless of the position).

In short, you are right, it depends on the values before the decimal point.

For example:

  • 12345678.1234567D //Next digit to the right will get rounded up
  • 1234567.12345678D //Next digit to the right will get rounded up

Full sample at:

Also, it is important to note that thinking double values as they are decimal values is not a good idea.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download