3

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 (sbb@gnu.org) and Paolo Bonzini (bonzini@gnu.org)

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?

prosseek
  • 182,215
  • 215
  • 566
  • 871

2 Answers2

2

According to a thread in a Smalltalk forum, this problem is caused by gst compiled with the -pie option, which is the default in many Linux distros, and maybe in Mac port too.

To solve this problem, compile gst with -no-pie option: Download gst 3.2.5 from https://ftp.gnu.org/gnu/smalltalk/, extract the tarball, and then compile & install

export CFLAGS='-no-pie'
export LDFLAGS='-no-pie'
./configure
make
sudo make install

This solution works fine on my Linux Mint PC.

amlo
  • 105
  • 1
  • 8
0

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
prosseek
  • 182,215
  • 215
  • 566
  • 871
  • What happens if you try with suffix d instead of e? – aka.nice Jun 18 '13 at 22:41
  • @aka.nice: 1d1 or 1d3 -> OK, 1d0 -> crash 1d -> crash – prosseek Jun 18 '13 at 23:07
  • 1
    I asked because e exponent will create a single precision floating point (FloatE) while d will creates a double precision (FloatD). Presumably FloatD is the default if you don't provide an exponent (There is a FloatD on your stack dump). So it sounds like a buggish behavior of printOn:special: that shows up with double precision... – aka.nice Jun 18 '13 at 23:16