float equality

Mike James foo at bar.com
Tue Feb 22 04:44:47 PST 2011


"Andrei Alexandrescu" <SeeWebsiteForEmail at erdani.org> wrote in message 
news:ijuub9$tv5$1 at digitalmars.com...
> On 2/21/11 4:48 AM, Jonathan M Davis wrote:
>> On Monday 21 February 2011 01:55:28 Walter Bright wrote:
>>> Kevin Bealer wrote:
>>>> 1. To solve the basic problem the original poster was asking -- if you
>>>> are working with simple decimals and arithmetic you can get completely
>>>> accurate representations this way.  For some cases like simple 
>>>> financial
>>>> work this might work really well. e.g. where float would not be because
>>>> of the slow leak of information with each operation.  (I assume real
>>>> professional financial work is already done using a (better)
>>>> representation.)
>>>
>>> A reasonable way to do financial work is to use longs to represent 
>>> pennies.
>>> After all, you don't have fractional cents in your accounts.
>>>
>>> Using floating point to represent money is a disaster in the making.
>>
>> Actually, depending on what you're doing, I'm not sure that you can 
>> legally
>> represent money with floating point values. As I understand it, there are 
>> definite
>> restrictions on banking software and the like with regards to that sort 
>> of thing
>> (though I don't know exactly what they are).
>
> This is a long-standing myth. I worked on Wall Street and have friends who 
> have been doing it for years. Everybody uses double.
>
> Andrei
>

Now we know who to blame for the downfall of the financial sector :-)

-=mike=- 




More information about the Digitalmars-d mailing list