------art_70564_15187163.1167148871083
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

On 12/26/06, Dermot Moynihan <der_moyn / onetel.com> wrote:
>
> Thanks Jeroen.
>
> Been doing a bit of reading on 'ceil' and 'floor' and am wondering if
> you have to know the actual number you are going to be working on in
> order to use them. Because I don't know what that number will be. Did
> you skim read that post - I gave some examples to try to make that
> point. Or have I just misunderstood how to use 'ceil' or 'floor'.
>
> I would have thought this would be a fairly mundane task. After all if
> one wants 1 and a bit ice creams or whatever, he must get two not one.
> So, rounding up is surely pretty important.
>
> Been experimenting with a thing called 'round' but that rounds up if the
> figure after the decimal point is .5 or greater, otherwise it rounds
> down. But I need it always UP if there is greater than zero after the
> decimal.
>
> Just to sum up again: what I'm looking for is a way of always rounding
> up a floating point number that arrives after some calculations. The
> answer will vary as a result of the figures used in the calculation
> varying.
> e.g. if the final number is 6.1234 I want it rounded up to 7.
> If the final number is 23.025875 I want it rounded up to 24.
> However, if 17.0 then have it stay 17.
> Or if 21.0 stay 21. And so on.
>
> I suppose what I need is some way of saying:
> IF the answer is a floating point decimal number round it up.
> If there is nothing after the decimal point (e.g. 46.0) leave it alone
> (46).
>
> Thanks for your help.
>
> Dermot

Yeah, the ceil method always rounds a float up to the next integer
apparently.

C:\ruby\programs>irb
irb(main):001:0> miscNum  .0
4.0
irb(main):002:0> miscNum.ceil
4
irb(main):003:0> miscNum  .01
4.01
irb(main):004:0> miscNum.ceil
5

------art_70564_15187163.1167148871083--