Help with dividing and rounding
Author Message Help with dividing and rounding

It sounds simple, but I've yet to discover the answer.

I need to divide a group into hotel rooms, with four to a room.  My
problem is:  a group of 29, for example, would need 8 rooms.  Standard
division and rounding, though, returns a result of 7 rooms.

The next step:  We pay \$25 for each "extra pillow".  For example, my
group of 29 has three unused pillows, and would need to be billed an

Question #1:  How do a calculate and round a given group number so that
if it does not divide evenly by four it is rounded to the next higher
number?

Question #2:  How do I calculate the number of unused pillows in a
group, and apply the \$25 per pillow charge?

Dale Kendrick

Tue, 06 Mar 2001 03:00:00 GMT  Help with dividing and rounding

The Mod function gives the remainder from dividing ane number by another
number.  The logical >0 is a binary test that returns true (=1) or false (=0)
if there is a remainder (i.e. extra people).

Number of rooms:
int(# of people/# to a room) + 1*(mod(# of people,# to a room)>0)

# extra spaces
mod(# of people/# to a room)

-Dave

Quote:

> It sounds simple, but I've yet to discover the answer.

> I need to divide a group into hotel rooms, with four to a room.  My
> problem is:  a group of 29, for example, would need 8 rooms.  Standard
> division and rounding, though, returns a result of 7 rooms.

> The next step:  We pay \$25 for each "extra pillow".  For example, my
> group of 29 has three unused pillows, and would need to be billed an

> Question #1:  How do a calculate and round a given group number so that
> if it does not divide evenly by four it is rounded to the next higher
> number?

> Question #2:  How do I calculate the number of unused pillows in a
> group, and apply the \$25 per pillow charge?

> Thanks in advance, of course.

> Dale Kendrick

Tue, 06 Mar 2001 03:00:00 GMT

 Page 1 of 1 [ 2 post ]

Relevant Pages