Search code examples
macossmalltalkgnu-smalltalk

floating point raises divide by zero error in GNU smalltalk (gst)


I installed gnu small talk in my Mac using port.

sudo port install gst

The version is 3.2.5

gst -v
GNU Smalltalk version 3.2.5
Copyright 2009 Free Software Foundation, Inc.
Written by Steve Byrne ([email protected]) and Paolo Bonzini ([email protected])

It seems to be working fine, but when I tested floating point number, I got divide by zero error message.

st> 123.323
Object: 1 error: The program attempted to divide a number by zero
ZeroDivide(Exception)>>signal (ExcHandling.st:254)
SmallInteger(Number)>>zeroDivide (SysExcept.st:1426)
Fraction>>setNumerator:setDenominator: (Fraction.st:485)
Fraction class>>numerator:denominator: (Fraction.st:66)
Fraction>>- (Fraction.st:151)
FloatD(Float)>>printOn:special: (Float.st:533)
FloatD(Float)>>printOn: (Float.st:436)
FloatD(Object)>>printString (Object.st:534)
FloatD(Object)>>printNl (Object.st:571)
st> 

I could bypass this issue by attaching "e0".

st> 123.323e0
123.323

However, I still get an error with some numeric operations involving floating point numbers.

st> 1.1 sin
Object: 1 error: The program attempted to divide a number by zero
ZeroDivide(Exception)>>signal (ExcHandling.st:254)

Sometimes it works fine.

st> 3.14 sin
0.0016

What's wrong with this?


Solution

  • I guess I need to attach e0 to all the floating point numbers.

    st> 1.1e0 sin
    0.8912074
    

    Or even with just e only

    st> 1.1e sin
    0.8912074