comp.lang.ada
 help / color / mirror / Atom feed
From: "J-P. Rosen" <rosen@adalog.fr>
Subject: Re: can Ada give run-time error or warning for integer division with non-zero remainder?
Date: Sun, 12 Aug 2012 07:45:52 +0200
Date: 2012-08-12T07:45:52+02:00	[thread overview]
Message-ID: <50274310.80007@adalog.fr> (raw)
In-Reply-To: <k07028$eok$1@speranza.aioe.org>

Le 12/08/2012 03:14, Nasser M. Abbasi a �crit :
> 
> In Ada when dividing 2 integers, the result is an integer
> with the remainder ignored.  Hence 3/2 gives 1
> [...]
> Is there any kind of run-time switch to tell it to
> check for this? I know I can always add logic myself to
> check for this in the code, using rem() for example (which
> might be the better solution actually) but I was just
> wondering if there is a run-time switch for this.
> 
Fortunately not!

Dividing integers uses the integer division. If you want something else,
don't use integer division.

Having the outcome of an operation depend on a switch would imply that
you cannot predict the result of a program by reading it!

-- 
J-P. Rosen
Adalog
2 rue du Docteur Lombard, 92441 Issy-les-Moulineaux CEDEX
Tel: +33 1 45 29 21 52, Fax: +33 1 45 29 25 00
http://www.adalog.fr



  reply	other threads:[~2012-08-15  2:48 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-12  1:14 can Ada give run-time error or warning for integer division with non-zero remainder? Nasser M. Abbasi
2012-08-12  5:45 ` J-P. Rosen [this message]
2012-08-12  6:45 ` Dmitry A. Kazakov
2012-08-12  7:16 ` Per Sandberg
2012-08-12 14:03   ` Brad Moore
2012-08-12 14:19 ` Robin Vowels
replies disabled

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