hi there

hi there,

we are using DevExpress components,

there is one field TcxCurrencyEdit ( field 1)
there is another one on cxGrid which is FooterSummaryValue[i], sum of all values on a colum (field 2)

we try to display some indicator if above two fields have the same value then display green otherwise display red.

weird thing happens yesterday the color display red, through debug both of fields have the value as 4566996

but when I do (field 1.value - field 2.value) I got the following number: 9.31322574615479e-10

And I googled that number and truns out it's a magic number as
1 GiB to EiB = 9.31322574615479E-10 exbibytes

so I don't know what is happend here, I think something to do with field one type is double and field 2 type is variant

but even I convert field 2 as double still get the same.

can someone please help to figure this out?

thanks

Justin

Comments

  1. Check GetPrecisionMode / SetPrecisionMode of your application and make sure the Currency values are never transfered, stored or compared as anything other than Currency.
    The type of TcxCurrencyEdit.Value is Double, use the display text as string instead and convert it to currency yourself.

    What you are experiencing is floating point math. Math in Delphi is not broken. For more information check http://floating-point-gui.de/

    ReplyDelete

Post a Comment