Article View: comp.lang.prolog
Article #1004Sicstus Prolog Questions
From: Dr. Ranga R. Vemuri
Date: Sun, 22 Jul 1990 11:09
Date: Sun, 22 Jul 1990 11:09
61 lines
2745 bytes
2745 bytes
(1)
I am using Sicstus0.6 prolog to write a program with a LOT of
floating-point operations. I am having problems in getting
the program perform these floating point operations correctly.
It seems that, after performing a few thousand operations,
the floating point results start overflowing or underflowing.
For example, here is a simple psuedo random number generator.
IX is the seed. This produced about 700 to 800 random numbers correctly
(I checked them through other means) and then started giving out 0's;
The reason, I found through tracing, invariably was an underflow/overlow.
At that point, the prolog system wouldn't do even simple arithmetic
properly: for eg, `A is 1/6' produces `A = 4.32583271660369e-308' !!!
random(IX, NewIX, Rand):-
A is 16807,
B15 is 32768,
B16 is 65536,
P is 2147483647,
XHI is IX//B16,
XALO is (IX-(XHI*B16))*A,
LEFTLO is XALO//B16,
FHI is (XHI*A) + LEFTLO,
K is FHI//B15,
ModifiedIX is ( ((XALO-(LEFTLO*B16))-P) + (FHI-(K*B15))*B16) + K,
((ModifiedIX < 0, NewIX is ModifiedIX + P); NewIX is ModifiedIX),
Rand is NewIX*4.656612875e-10.
Any suggestions on how I can try and get of out this problem will be
greatly appreciated.
(2)
As one way of avoiding the above problem, I have tried to implementing
my floating point routines in C and tried to interface them using
the foreign language interface feature of Sisctus. I couldn't get
that working either. 'load_foreign_files' gives me either
an 'illegal usage' message or says 'myCfile.o undefined'.
'foreign' and 'foreign_file' also give 'illegal usage' messages.
The Sictus0.6 documet I have seems to imply, however, that this feature is
fully implemented....
Any help here is appreciated too......
(3)
Is there a free-of-charge (ftp'able ??) or commercial prolog
which is known to be good in handling both floating point arithmetic
and foreign function interface ??
Thanks.
- Ranga
ranga@uceng.uc.edu
_________
Ranga Vemuri ranga@uceng.uc.edu
Laboratory for Digital Design Environments (513)-556-4784
M.L. 30, Dept. Electrical & Computer Engineering (513)-556-4769
University of Cincinnati, Cincinnati, OH 45221, USA
Technical Details
Message-ID:
<5574@uceng.UC.EDU>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!mailrus!iuvax!uceng!rangaShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!mailrus!iuvax!uceng!ranga From: ranga@uceng.UC.EDU (Dr. Ranga R. Vemuri) Newsgroups: comp.lang.prolog Subject: Sicstus Prolog Questions Keywords: Sicstus0.6 Prolog, Floating Point Arithmetic, Foreign Fns. Message-ID: <5574@uceng.UC.EDU> Date: 22 Jul 90 11:09:12 GMT Organization: College of Engg., Univ. of Cincinnati Lines: 61