Article 56PD8 Ceiling of float number - How?

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?

Thankslatest?d=yIl2AUoC8zA latest?i=fGgQPoop3aY:288weJfzL7g:F7zBnMy latest?i=fGgQPoop3aY:288weJfzL7g:V_sGLiP latest?d=qj6IDK7rITs latest?i=fGgQPoop3aY:288weJfzL7g:gIN9vFwfGgQPoop3aY
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments