* Integer Division
@ 1998-08-05 0:00 jsanchor
1998-08-05 0:00 ` Samuel Tardieu
0 siblings, 1 reply; 2+ messages in thread
From: jsanchor @ 1998-08-05 0:00 UTC (permalink / raw)
Hi guys, I have a question. It is so simple that it seems stupid. I was doing
a simple arithmetic operation 10/3. Now, I want the INTEGER division to
return the next whole number (i.e. 4). I know in floating_point type they
have an attribute called 'Ceiling. What about integer types? Currently, I am
doing a division operation B := A/3, & then a 'rem' operation if A rem 3 /=
0 then B = B + 1; Is there a nicer method?
Thank you in advance.
Sincerely,
Jay S.
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Integer Division
1998-08-05 0:00 Integer Division jsanchor
@ 1998-08-05 0:00 ` Samuel Tardieu
0 siblings, 0 replies; 2+ messages in thread
From: Samuel Tardieu @ 1998-08-05 0:00 UTC (permalink / raw)
To: jsanchor
>>>>> "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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~1998-08-05 0:00 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-08-05 0:00 Integer Division jsanchor
1998-08-05 0:00 ` Samuel Tardieu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox