English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

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: 2006-12-08 (18:37)
From: Brian Hurt <bhurt@j...>
Subject: Re: [Caml-list] if (n:int) < 0 then (-n) > 0 is FALSE
Mattias Engdegård wrote:

>>I wouldn't call it a bug. It looks like modulo arithmetic to me.
>Let's not make a virtue of necessity. The type "int" was likely designed
>with the intent to provide a type that could be used for actual integers
>in a variety of circumstances, while giving good performance. The modulo
>semantics is rarely useful (especially the 30-bit signed variety) but
>is the price paid for reasonable performance with a simple implementation.
Actually, the modulo behavior comes out of how the CPU designers made 
the CPUs work decades ago.  It was very easy for them to just drop all 
those extra bits (or not even compute them).  And, of course, now that 
behavior is cast in stone...