comp.lang.ada
 help / color / mirror / Atom feed
* Modular integers
@ 2003-10-28 12:13 Lars
  2003-10-28 12:28 ` David C. Hoos
  2003-10-29  1:51 ` Raising exceptions (was: Modular integers) Jeffrey Carter
  0 siblings, 2 replies; 12+ messages in thread
From: Lars @ 2003-10-28 12:13 UTC (permalink / raw)


Hi,

I was able to create an unsigned 64-bit integer using

    type unsigned_64_bit_integer is mod 2**64;

Then I defined a subtype:

    subtype safe_unsigned_64_bit_integer is unsigned_64_bit_integer range 0
.. 2**64-1;

When a variable of type unsigned_64_bit_integer contains 2**64-1 and you add
1, it is "reset" to 0, as expected.
When a variable of type safe_unsigned_64_bit_integer contains 2**64-1 and
you add 1, no exception is raised and it is "reset" to 0.

Why is that? Shouldn't the compiler be able to insert a check that throws an
exception if an overflow occurs?

-Lars





^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2003-10-29 12:16 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-10-28 12:13 Modular integers Lars
2003-10-28 12:28 ` David C. Hoos
2003-10-28 12:48   ` Lars
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

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