std.math performance (SSE vs. real)

Andrei Alexandrescu via Digitalmars-d digitalmars-d at puremagic.com
Sun Jun 29 09:54:44 PDT 2014


On 6/29/14, 8:50 AM, Iain Buclaw via Digitalmars-d wrote:
> On 29 June 2014 15:59, Andrei Alexandrescu via Digitalmars-d
> <digitalmars-d at puremagic.com> wrote:
>> On 6/28/14, 9:36 PM, H. S. Teoh via Digitalmars-d wrote:
>>>
>>> On Sat, Jun 28, 2014 at 05:16:53PM -0700, Walter Bright via Digitalmars-d
>>> wrote:
>>>>
>>>> On 6/28/2014 3:57 AM, Russel Winder via Digitalmars-d wrote:
>>>
>>> [...]
>>>
>>>>> Or indeed when calculating anything to do with money.
>>>>
>>>>
>>>> You're better off using 64 bit longs counting cents to represent money
>>>> than using floating point. But yeah, counting money has its own
>>>> special problems.
>>>
>>>
>>> For counting money, I heard that the recommendation is to use
>>> fixed-point arithmetic (i.e. integer values in cents).
>>
>>
>> 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.
>>
>> Andrei
>>
>
> I would have thought money would use fixed point decimal floats.

And what meaningful computation can you do with such? Using fixed point 
for money would be like the guy in Walter's story rounding to two 
decimals after each step in the calculation.

Even for a matter as simple as average price for a share bought in 
multiple batches you need floating point.


Andrei



More information about the Digitalmars-d mailing list