Version française
Home     About     Download     Resources     Contact us    
Browse thread
if (n:int) < 0 then (-n) > 0 is FALSE
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Martin Jambon <martin1977@l...>
Subject: Re: [Caml-list] if (n:int) < 0 then (-n) > 0 is FALSE
On Thu, 7 Dec 2006, Pal-Kristian Engstad wrote:

> To find that it loops forever. The reason is that 1024*1024*1024=2^30
> cannot be represented as a positive number on 32-bit platforms, hence it
> silently converts it to -1073741824, or -2^30. The reason this loops
> again is that -n = -(-20^30) = -20^30......, still negative!
>
> This is obviously a bug - has it since been fixed? But more alarmingly -
> why is there no warning?

For what it's worth, you can have a look at "Overflow":

  http://sebastien.ailleret.perso.cegetel.net/caml/

(I haven't tried it)


Martin

--
Martin Jambon, PhD
http://martin.jambon.free.fr