In Delphi, double is floating point, but currency is NOT. With a double, "1.4" is stored as "1.4", while an equivalent Currency value is stored as "14 / 10". Note that the latter is integral, so it doesn't have rounding errors.
The other way to represent perfectly consistent numbers is the way DECIMAL (in SQL) is implemented, which is just as a string of characters. Then you do digit-wise integer operations (elementary school style, with carrying and borrowing and stuff), which retains perfect accuracy. cheers, barneyb On 12/6/05, Paul Vernon <[EMAIL PROTECTED]> wrote: > > So you're saying that Deplhi produces a non-standard result? :P > > > > No, but interestingly, depending on which type I declare, I get different > results... > > If I declare the types of the vars as Double, then I get a rounding error. > If I choose extended (much greater accuracy than the processor manages by > itself), I get 0. So, from this, it would appear that Delphi is defaulting > its types to something that bypasses the hardware and uses its own libraries > to calculate. If I use a type that maps to a hardware type then the error is > there... I agree that this is a hardware issue. > > Even if I multiply the result by a very large number, with Extended, Comp > and Currency I still get 0. With single, double, and real48 I get rounding > issues. > > Delphi 7 types. > > Type Min Max > Precision Size in bytes > Real48 2.9 x 10^-39 1.7 x 10^38 11-12 > 6 > Single 1.5 x 10^-45 3.4 x 10^38 7-8 > 4 > Double 5.0 x 10^-324 1.7 x 10^308 15-16 8 > Extended 3.6 x 10^-4951 1.1 x 10^4932 19-20 > 10 > Comp -2^63+1 2^63 -1 19-20 > 8 > Currency -922337203685477.5808 922337203685477.5807 19-20 > 8 > > Paul > -- Barney Boisvert [EMAIL PROTECTED] 360.319.6145 http://www.barneyb.com/ Got Gmail? I have 100 invites. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Find out how CFTicket can increase your company's customer support efficiency by 100% http://www.houseoffusion.com/banners/view.cfm?bannerid=49 Message: http://www.houseoffusion.com/lists.cfm/link=i:4:226328 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

