Subject: Re: handling small numbers

From: [email-masked]
Date: Wed, 10 May 2000 08:21:55 +0200

> 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.

-- 
clemens                            ([email-masked], pgp key available)