rounding up a floating point number to the nearest integer.

I need to round up a floating point number to the nearest integer. So 2.3 would become 3 instead of 2 which is what happens if i use 2.3.round.

does anyone know of a simple way to do this?

if not could you please point my in the right direction for a more complicated way.

Thank you.

Round will round to the nearest integer. This is not always down. The builtin method :ceil is the one your after here.

2.3.ceil #=> 3

Cheers

Daniel

brains hgs 31 %> irb irb(main):001:0> 2.3.ceil => 3 irb(main):002:0> quit brains hgs 32 %>

        Hugh

Make sure that, if you have negative values, that you understand that “up” means “toward positive Infinity”

-2.3.ceil #=> -2

-Rob

Rob Biedenharn http://agileconsultingllc.com

Rob@AgileConsultingLLC.com

Thanks