[squeak-dev] Decimals as fractions

K K Subbu kksubbu.ml at gmail.com
Sun Apr 7 03:10:52 UTC 2019


Squeak compiler compiles numbers like "3.4" into SmallFloat types. But 
Squeak can also handle number pairs like Point and Fractions. Has anyone 
considered decimals into fractions, instead? Like how we treat fractions 
in real life? $0.02 is really 2/100th of a dollar. I wouldn't want it to 
float ;-).

Squeak could compile fix points like "3.4" into fractions like "34/10" 
and compile into float only if an explicit exponent is given like in 
"3.4e0". This would help us maintain accuracy as long as possible in 
fraction arithmetic we use in daily life. e.g.

3.41 - 3.40 0.010000000000000231
((341/100) - (340/100)) asFloat 0.01

Regards .. Subbu

More information about the Squeak-dev mailing list