DoubleEditBox numbers cut-off

Editors for WPF Forum

Posted 15 years ago by Dmitry Kaganovich
Version: 9.1.0500
Platform: .NET 3.5
Environment: Windows Vista (32-bit)
Avatar
<editors:DoubleEditBox Value="58.123456789012344" Format="G" />

for some reason, displayed value is always limited to 13 digits after the period. (the last "44" are not displayed

[Modified at 06/24/2009 10:45 AM]

Comments (4)

Posted 15 years ago by Andy Hardin
Avatar
15 digits is the default precision for doubles when using the G format string. See G at MSDN at http://msdn.microsoft.com/en-us/library/dwhawy9k.aspx.
Posted 15 years ago by Dmitry Kaganovich
Avatar
I've changed it to N18 and i'm still limited to 15 decimal places. is it something that .NET is doing?

[Modified at 06/24/2009 11:14 AM]
Posted 15 years ago by Dmitry Kaganovich
Avatar
I was thinking more about this... and i'm not sure double itself is very meaningfull at that precision level, so i guess it anwers my question...don't use anything >15 digits after the period
Posted 15 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Dmitry,

We are simply using the Double.ToString method to convert the double value to a string. So in your case, calling ToString("N18") results in the string you see. This is independent of the DoubleEditBox.

The double type has a limited precision of 15-16 digits, and specifying a larger number (e.g. 18) will only append zeros. I'm not sure why using the "R" format specifier shows the last two digits though, but probably just has to do with how Microsoft implemented it. When you start getting to the limits of what a double can hold, you will get some "unexpected" results (really the results defined in the IEEE Standard for Binary Floating-Point Arithmetic, but are not what most people would expect). For example, if you change your number to "58.123456789012345" even the "R" format specifier is incorrect (because the double type cannot represent that number).

More information can be found at IEEE 754-1985 and IEEE 754-2008 on Wikipedia.


Actipro Software Support

The latest build of this product (v24.1.2) was released 1 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.