comp.lang.ada
 help / color / mirror / Atom feed
From: Samuel Tardieu <sam@ada.eu.org>
To: jsanchor@cs5.dasd.honeywell.com
Subject: Re: Integer Division
Date: 1998/08/05
Date: 1998-08-05T00:00:00+00:00	[thread overview]
Message-ID: <m3vho7xr7f.fsf@zaphod.enst.fr> (raw)
In-Reply-To: 6qa43u$eip$1@nnrp1.dejanews.com

>>>>> "Jay" == jsanchor  <jsanchor@cs5.dasd.honeywell.com> writes:

Jay> Hi guys, I have a question. It is so simple that it seems
Jay> stupid. I was doing a simple arithmetic operation 10/3. Now, I
Jay> want the INTEGER division to return the next whole number
Jay> (i.e. 4). I know in floating_point type they have an attribute
Jay> called 'Ceiling. What about integer types? Currently, I am doing
Jay> a division operation B := A/3, & then a 'rem' operation if A rem
Jay> 3 /= 0 then B = B + 1; Is there a nicer method?

If you work with positive numbers,

   B := (A + 2) / 3;

will do the job (and (A+(D-1))/D in general).

  Sam
-- 
Samuel Tardieu -- sam@ada.eu.org




      reply	other threads:[~1998-08-05  0:00 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-08-05  0:00 Integer Division jsanchor
1998-08-05  0:00 ` Samuel Tardieu [this message]
replies disabled

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