comp.lang.ada
 help / color / mirror / Atom feed
From: "Lars" <lars-remove_me-m@gmx.net>
Subject: Re: Modular integers
Date: Tue, 28 Oct 2003 13:48:22 +0100
Date: 2003-10-28T13:48:22+01:00	[thread overview]
Message-ID: <bnloh2$q3d$03$1@news.t-online.com> (raw)
In-Reply-To: Pftnb.86846$5n.57615@bignews5.bellsouth.net

Yes, it is not "reset".  I don't know a better word to describe it ...

Why couldn't the compiler insert code that checks what the upper limit of
the type is, then substracts the current value of the variable from the
upper limit to see if the difference is bigger or equal to the number you
want to add? If it is not, it could throw an exception ...


> No.  By definition modular numbers cannot "overflow."  In fact, to say the
> value
> is "reset" to 0 is incorrect.  0 simply follows 2**64 - 1.
>
> You can declare a _signed_ 64-bit integer type which will overflow when
> adding
> 1 to 2**63-1, or underflow when subtracting 1 from -(2**63).





  reply	other threads:[~2003-10-28 12:48 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-10-28 12:13 Modular integers Lars
2003-10-28 12:28 ` David C. Hoos
2003-10-28 12:48   ` Lars [this message]
2003-10-28 14:13     ` Vinzent 'Gadget' Hoefler
2003-10-28 16:55       ` Lars
2003-10-28 18:50         ` David C. Hoos
2003-10-28 20:46           ` Lars
2003-10-29  8:30         ` Vinzent 'Gadget' Hoefler
2003-10-29 10:39           ` Jean-Pierre Rosen
2003-10-29 12:16             ` Vinzent 'Gadget' Hoefler
2003-10-29  1:51 ` Raising exceptions (was: Modular integers) Jeffrey Carter
2003-10-29  3:02   ` Raising exceptions Hyman Rosen
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox