Subject: Re: handling small numbers

From: Jan Wielemaker <[email-masked]>
Date: Wed, 10 May 2000 09:49:27 +0200

On Wed, 10 May 2000, [email-masked] wrote:
>> Richard A. O'Keefe (Wed 10.0500-14:57):
>> It has been possible to go off and do something else for longer than
>> SWI Prolog has existed, thanks to the freely available LONG.PL.
>
>where can i get LONG.PL?
>
>>     ?- quotient_and_remainder(70000, 70000, 0, 10000, Q, R).
>> 
>> blows up:
>>     ERROR: ///2: Type error: `integer' expected, found `4.9e+09'
>>     ^  Exception: (7) _G454 is 4.9e+09//10000 ? 
>> 
>> [...]
>> 
>> >From my point of view, the problem here is a bug in SWI Prolog.
>> It has raise the wrong exception and the wrong point.
>> The *real* problem is that the multiplication of 70000 by 70000
>> overflowed.
>
>agreed.  the exception is ok, but should be raised earlier on the integer
>multiplication overflow.  if type promotion were to be employed, it could
>engage bigints, but only if all operators were overloaded properly and the
>external representation wouldn't change.  and since this is a tricky thing,
>one should silently use bigints in the first place, =unless= the user is
>advised of the restricted range of input values to quotient_and_reminder/6.
>not doing so and not using a bigint package is bad design, in other words,
>doing so or using a bigint package is good design 7^)
>
>> Anything that separates the symptom from the cause is regrettable.
>
>very true.  i'd like to see this attitude applied to this discussion thread.

All in all, I think I vote for the introduction of a prolog flag. 
Basically, to an engineer 100000000 =:= 100000000.0 (and =~=
100000000.1), but to a mathematician this is complete nonsense (and
actually floats by themselves are very close to nonsense :-).

This flag can also deal with 4.5 @< 3, which is true according to ISO
Prolog, but false in SWI-Prolog default's behaviour (true if the iso
flag is set to true).  To an engineer, doing sort/2 on an array of mixed
floats and ints and getting all floats in front is pretty weird.

So, this flag should basically tell Prolog whether or not floats and
ints should both be regarded as coming from one space or not.  A
suggestion for a good name?

	Regards --- Jan