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
additional $75 per night.

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
 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
> additional $75 per night.

> 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
 
 [ 2 post ] 

 Relevant Pages 

1. Round 0.5 is rounded down instead of UP!!!

2. ROUND not accurating rounding/truncating

3. Round 0.5 is rounded down instead of UP!!!

4. Round-and-round with passwords

5. Help: divide by zero

6. Help: Upsize97 and divide by zero error... URGENT

7. Help-Divide by Zero Error

8. Divide SQL Error PLEASE HELP

9. Help Divide by Zero Error in 7.0

10. LCK divide by zero problem HELP!!!

11. Help with Rounding Float

12. Average rounding down--help


 
Powered by phpBB® Forum Software