std.math performance (SSE vs. real)

Don via Digitalmars-d digitalmars-d at puremagic.com
Mon Jun 30 04:57:03 PDT 2014


On Sunday, 29 June 2014 at 18:13:59 UTC, Russel Winder via 
Digitalmars-d wrote:
> On Sun, 2014-06-29 at 07:59 -0700, Andrei Alexandrescu via 
> Digitalmars-d
> wrote:
> […]
>
>> A friend who works at a hedge fund (after making the rounds to 
>> the NYC large financial companies) told me that's a myth. Any 
>> nontrivial calculation involving money (interest, fixed 
>> income, derivatives, ...) needs floating point. He never 
>> needed more than double.
>
> Very definitely so. Fixed point or integer arithmetic for simple
> "household" finance fair enough, but for "finance house" 
> calculations
> you generally need 22+ significant denary digits to meet with 
> compliance
> requirements.

Many people seem to have the bizarre idea that floating point is 
less accurate than integer arithmetic. As if storing a value into 
a double makes it instantly "fuzzy", or something.
In fact, providing that the the precision is large enough, every 
operation that is exact in integers, is exact in floating point 
as well.
And if you perform a division using integers, you've silently 
lost precision.
So I'm not sure what benefit you'd gain by eschewing floating 
point.





More information about the Digitalmars-d mailing list