Symbol for infinity

8 views
Skip to first unread message

hayri

unread,
Sep 7, 2010, 8:22:12 AM9/7/10
to ETALIS
Hi, is there a predefined symbol for (positive/negative) infinity in
Etalis? I would like to compare some values with infinity but I
couldn't find the symbol.

Thanks
hayri

Paul Fodor

unread,
Sep 7, 2010, 11:46:47 AM9/7/10
to eta...@googlegroups.com
Each Prolog language has a different equivalent for MAXINT while some
languages don't even consider having something like this.
What do you mean compare with infinite? Any value is less than
infinite and greater than minus infinite. Anyway, I assume that you
want to test if a variable is a number or a float versus an atom or a
compound term, so you can use the predicates here:
http://www.swi-prolog.org/pldoc/doc_for?object=section(2,'4.5',swi('/doc/Manual/typetest.html'))

XSB has some predefined values (MAXINT), but other Prologs don't
define anything. I assume that you are using SWI, so I looked in the
SWI manual, but I couldn't find anything like that. I know from my own
experience that when I was writing the datime library, I wanted to
transform any date into a numeric value and I couldn't because the
number of seconds was bigger than what SWI could represent.

My advice is to define your own value for the maximum numbers that you allow.
my_maxnumber(1000000).

and then use it where you need in the code:

...X...,
my_maxnumber(MAX),
(MAX > X
-> ( do your stuff )
; ( write('Errror: '), write(X), write(' is too big.'), nl )
),
...

Paul.

Reply all
Reply to author
Forward
0 new messages