Ceiling of float number - How?
by ddenial from LinuxQuestions.org on (#56PD8)
Hello All
How do I get the ceiling of the float number? I don't want float to be rounded to nearest.
For example, 11.2, 11.5 11.8 should round to its ceiling 12
I don't want traditional rounding like 11.2 = 11 and 11.8 = 12
I searched the web, but all I get is how to use a modulus trick between two numbers and finding its ceiling.
But I don't have two numbers, I only have a single float number which I derived from other complex maths. Now I want its ceiling.
The printf gives traditional rounding
Code:$ val1=11.2
$ val2=11.8
$ printf "%.f\n" $val1
11
$ printf "%.f\n" $val2
12For both values I want the result to be 12.
How do I do that?
Thanks


How do I get the ceiling of the float number? I don't want float to be rounded to nearest.
For example, 11.2, 11.5 11.8 should round to its ceiling 12
I don't want traditional rounding like 11.2 = 11 and 11.8 = 12
I searched the web, but all I get is how to use a modulus trick between two numbers and finding its ceiling.
But I don't have two numbers, I only have a single float number which I derived from other complex maths. Now I want its ceiling.
The printf gives traditional rounding
Code:$ val1=11.2
$ val2=11.8
$ printf "%.f\n" $val1
11
$ printf "%.f\n" $val2
12For both values I want the result to be 12.
How do I do that?
Thanks