Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Brian Hurt <bhurt@janestcapital.com>
To: "Mattias Engdegård" <mattias@virtutech.se>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] if (n:int) < 0 then (-n) > 0 is FALSE
Date: Thu, 07 Dec 2006 15:02:27 -0500	[thread overview]
Message-ID: <45787353.2040302@janestcapital.com> (raw)
In-Reply-To: <200612071943.kB7JhC522308@virtutech.se>

[-- Attachment #1: Type: text/plain, Size: 1157 bytes --]

Mattias Engdegård wrote:

>>It's not a bug -- you're relying on 32bit ints when OCaml has only
>>31bit ints (on 32-bit arch). In C (for example), if you use a plain
>>int (I believe it'll default to signed), you get the exact same
>>behaviour when the number overflows 2^31.
>>    
>>
>
>(Signed overflow is not legal in C (undefined behaviour), and a decent
>compiler will warn this can be detected statically.)
>
>Of course it is a bug - a design bug, since the behaviour is intended
>and documented, but still a bug. But getting numbers, even integers,
>right in every respect is hard, and involves trade-offs between
>performance, correctness and convenience.
>
>I would love to have a fast unboxed integer type that automatically
>overflows to bignum, but it would be a tad slower than the current "int".
>  
>

I find it interesting that the languages I know use fixed-size integers 
(Ocaml, C, C++, Java, C#, Fortran, Pascal) are at or near the top of the 
great computer language shootout, while the languages I know don't 
(Perl, Python) are near the bottom.  Not that I'm saying that this is 
the case, it's just an interesting dichotomy.

Brian


[-- Attachment #2: Type: text/html, Size: 1576 bytes --]

  reply	other threads:[~2006-12-07 20:02 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-12-07 18:32 Pal-Kristian Engstad
2006-12-07 19:19 ` [Caml-list] " Jonathan Roewen
2006-12-07 19:43   ` Mattias Engdegård
2006-12-07 20:02     ` Brian Hurt [this message]
2006-12-08  2:37     ` skaller
2006-12-08 11:09       ` Mattias Engdegård
2006-12-08 17:48     ` Jon Harrop
2006-12-08 18:20       ` Mattias Engdegård
2006-12-08 18:37         ` Brian Hurt
2006-12-09  2:03           ` skaller
2006-12-07 21:13 ` Martin Jambon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=45787353.2040302@janestcapital.com \
    --to=bhurt@janestcapital.com \
    --cc=caml-list@inria.fr \
    --cc=mattias@virtutech.se \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox