Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
260
UltraNumericEditor : Rounding off input
posted

Hi,

We have a ultraNumericEditor control with "Numeric Type" property set to double. The maximum value that we want to be able to enter in this field is 999999999999999.99 (15,2). However when we enter this number, it gets changed to all 0s. We have the MaskInput as nnnnnnnnnnnnnnn.nn and the MaxValue is set to 1E+20. Are we doing something wrong?

Parents
No Data
Reply
  • 469350
    Verified Answer
    Offline posted

     Hi,

    The double data type is inherently imprecise. And I beleive DotNet only allows up to 15 significant digits. Since you have 17 digits here, the value gets rounded. 

    To see what I mean, try this code: 

    double d = 999999999999999.99;
    Debug.WriteLine(d.ToString());

    This will display:  "1E+15" which is "1000000000000000.00". This is 18 digits, and your mask only allows for 17, so the first digits is stripped out. 

    If you need this kind of precision, UltraNumericEditor was recently updated to support the decimal data type, which is more precised, so you might want to use that if you have a more recent version of the controls. If not, you can try using the UltraMaskedEditor control with a decimal data type.

Children