0

I use wpfToolkitExtended:DoubleUpDown and have problem with number larger than, for example "100000000". Control rounds numbers in some strange way. Every time I get different number in control after typing large number and press "enter" (negative or positive large number). Minimun and Maximum attributes do not help. Value is binded with float variable.

When I use wpfToolkitExtended:DecimalUpDown problem does not exist, rounded value for large numbers is always the same.

Does anyone know what happens with DoubleUpDown in this situation ? Will I get any performance or memory penalty if I use DecimalUpDown instead of DoubleUpDown.

Milos
  • 1,678
  • 4
  • 23
  • 49
  • Have you got example code of this ? If so I'll take a look. – netniV Sep 07 '15 at 22:25
  • I think that my code does not have to do anything with this error. The error occurs regardless of code behind. – Milos Sep 08 '15 at 12:18
  • Yes appreciated but if you had a test project or code I can try and debug what's going on. :) – netniV Sep 08 '15 at 13:42
  • Have you managed to put a small test together ? – netniV Sep 09 '15 at 22:38
  • I think that problem is because control is binded to float variable. float cannot represent every number, and for some bigger number which cannot be represented its just change the value to some which float can remember. – Milos Sep 10 '15 at 06:28
  • See my full answer below. It contains a link back to another post that fully explains the different between the types and why you'd get this rounding problem. – netniV Sep 10 '15 at 23:32

1 Answers1

0

Floats, doubles and decimals all operate differently. Floats use a precision factor to decide on the value of large numbers, as do doubles. Decimals are 100% precise on all numbers.

That is just a basic .NET and MSSQL principle. For more information on that see Difference between decimal, float and double in .NET?

So if you always need the number to be 100% use decimal. Floats / doubles can have a 1/3 rounding factor.

Edit:

Performance wise yes there is a hit for using decimal but unless you are talking a high end high capacity system you shouldn't notice it in my opinion. Especially if used from the start.

See Applications using Decimal versus double . . for more comments on this.

Community
  • 1
  • 1
netniV
  • 2,328
  • 1
  • 15
  • 24