Board index » delphi » Currency conversions (delphi bug or not ?)
cristianhaulica
![]() Delphi Developer |
Currency conversions (delphi bug or not ?)2006-03-08 04:03:12 PM delphi7 Hy all The problem orriginates in a DB (oracle) application where there is NUMBER field that I try to read "goodsModel.price := query.FieldAsCurrency FLD_ONE_TIME_PRICE); where price id of type Currency, an [i:eda889c689]FieldAsCurrency[/i:eda889c689] calls directly "[i:eda889c689]FieldByName(name).AsCurrency[/i:eda889c689] from [i:eda889c689]TQuery[/i:eda889c689], and returns [b:eda889c689]currency[/b:eda889c689] The problem is that for numbers greater tha [b:eda889c689]33333333333332 [/b:eda889c689](that's 14 digits), th returned value is somehow aproximative. (instead o [b:eda889c689]33333333333333 [/b:eda889c689]I ge [b:eda889c689]33333333333332.9984[/b:eda889c689] Why? :?: The strange part is I made the test procedure below [i:eda889c689 procedure TestCurr() va currTmp : currency doubleTmp : double begi currTmp := 33333333333333.0000 doubleTmp := currTmp currTmp := doubleTmp MessageDlg(currtostr(currtmp), mtCustom, [mbOK],0) end [/i:eda889c689 If I call this in my application, the returned value i [b:eda889c689]33333333333332.9984[/b:eda889c689], but if I make simple test application and call this same procedure I ge [b:eda889c689]33333333333333[/b:eda889c689]. As fas as I could check both applications have the same project opptions. :( The problem appeares to be related to some type conversions, but i the orriginal case there was no type conversion, and btw, currenc should support 20 digits precission for positive numbers..... so.. :?: I wander if there can be a compilation flag or something, to avoi this situation (as long as my test application works ok), but in th GUI part there is no settings difference between the test and th orriginal application Any ideea is appreciated HELP |