From: "Mattias Engdegård" <mattias@virtutech.se>
To: jonathan.roewen@gmail.com
Cc: pal_engstad@naughtydog.com, caml-list@inria.fr
Subject: Re: [Caml-list] if (n:int) < 0 then (-n) > 0 is FALSE
Date: Thu, 7 Dec 2006 20:43:12 +0100 [thread overview]
Message-ID: <200612071943.kB7JhC522308@virtutech.se> (raw)
In-Reply-To: <ad8cfe7e0612071119k6a9c51a4s79fae5838f5d6fa1@mail.gmail.com> (jonathan.roewen@gmail.com)
>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".
next prev parent reply other threads:[~2006-12-07 19:43 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 [this message]
2006-12-07 20:02 ` Brian Hurt
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=200612071943.kB7JhC522308@virtutech.se \
--to=mattias@virtutech.se \
--cc=caml-list@inria.fr \
--cc=jonathan.roewen@gmail.com \
--cc=pal_engstad@naughtydog.com \
/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