std.math performance (SSE vs. real)

Andrei Alexandrescu via Digitalmars-d digitalmars-d at puremagic.com
Sun Jun 29 15:37:16 PDT 2014


On 6/29/14, 11:13 AM, 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.

I don't know of US regulations that ask for such.

What I do know is I gave my hedge fund friend a call (today is his name 
day so it was as good a pretext as any) and mentioned that some people 
believe fixed point is used in finance. His answer was:

BWAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAAAAAAAAAAAAAAAAAAAAAAA!

I asked about how they solve accumulating numeric errors and he said 
it's on a case basis. Most of the time it's pennies for billions of 
dollars, so nobody cares. Sometimes there are reconciliations needed - 
so called REC's - that compare and adjust outputs of different algorithms.

One nice war story he recalled: someone was storing the number of 
seconds as a double, and truncate it to int where needed. An error of at 
most one second wasn't important in the context. However, sometimes the 
second was around midnight so an error of one second was an error of one 
day, which was significant. The solution was to use rounding instead of 
truncation.


Andrei




More information about the Digitalmars-d mailing list