Mats Carlsson wrote:
>>>>> One consequence of this floating-point contagion is that in a system
>>>>> with
>>>>>
>>>>> bigints - like SICStus - max/2 can now also throw an overflow exception:
>>>>> | ?- X is 234<<23423, Y is max(X,0.1).
>>>>>
>>>>> ! Evaluation error in argument 2 of is/2
>>>>> ! float_overflow at 2482014388617793184935802414678 [some more digits
>>>>> snipped away by me]
>> But that's simply a bug, isn't it? ECLiPSe says:
>>
>> ?- X is 234 << 23423, Y is max(X, 0.1).
>> X = 2482014388617793184935802414678453594506527110211601991200031311191...
>> Y = 1.0Inf
>> Yes (0.00s cpu)
>
> It's not a bug, it follows from the type coersion semantics that
> SICStus uses. One argument is a float => the value is a float.
No argument there - ECLiPSe uses the same semantics.
> But
> 234<<23423 can't be converted to a floating-point number: there are
> not enough bits in the exponent, which is what the exception is about.
I suppose you then also raise exceptions for anything like
?- X is (1 << 1100) + 1.0.
X = 1.0Inf
Yes (0.00s cpu)
What about explicit conversion?
?- X is float(1 << 1100).
X = 1.0Inf
Yes (0.00s cpu)
I guess one can argue both ways here: on one hand, the normal way
to deal with overflows in float arithmetic is to return an infinity
result, but you seem to say that int->float conversion is not a
normal float operation.
> P.S. What does "1.0Inf" mean?
Sorry, I should have mentioned that, it would have made things
clearer:
This is ECLiPSe's canonical syntax for positive float infinity
(produced by writeq and understood by the parser). Negative
infinity is -1.0Inf. The lack of defined syntax for infinity
is, by the way, another hole in the current standard.
Care to standardise this? Note that it is carefully chosen
such that it cannot be confused with other valid Prolog syntax.
-- Joachim
_______________________________________________
prolog-standard mailing list
prolog-standard_at_neve.di.ubi.pt
http://neve.di.ubi.pt/mailman/listinfo/prolog-standard
Received on Mon Jul 14 2008 - 13:01:02 EST
This archive was generated by hypermail 2.2.0 : Wed Sep 08 2010 - 23:28:17 EST