[squeak-dev] Decimals as fractions

K K Subbu kksubbu.ml at gmail.com
Mon Apr 8 11:37:03 UTC 2019


On 07/04/19 8:07 PM, Stéphane Rollandin wrote:
> 
>> 3.41 - 3.40 0.010000000000000231
>> vs
>> ((341/100) - (340/100)) asFloat 0.01
> 
> On my system:
> 
> [3.41 - 3.40] bench
>      --> '76,200,000 per second. 13.1 nanoseconds per run.'
> 
> [((341/100) - (340/100)) asFloat] bench
>      --> '1,230,000 per second. 816 nanoseconds per run.'
> 
> a := 341/100.
> b := 340/100.
> [a - b] bench
>      --> '4,050,000 per second. 247 nanoseconds per run.'

Thank you for the quick response. The slowdown is to be expected. Floats 
are immediate while Fractions are objects. I floated a strawman proposal 
to tradeoff accuracy for speed.

Regards .. Subbu


More information about the Squeak-dev mailing list