FW: ceiling function
Posted by
Krs5 on
Aug 08, 2011; 8:34am
URL: http://imagej.273.s1.nabble.com/ceiling-function-tp3683582p3683585.html
Hi Johannes,
Indeed. I was using
x=5.5;
x = -floor(-x);
y = floor(x);
print(x, y);
so how to write the x = -floor(-x) to get it to round up?
Kees
-----Original Message-----
From: Johannes Schindelin [mailto:
[hidden email]]
Sent: 08 August 2011 09:18
To: Straatman, Kees R. (Dr.)
Cc:
[hidden email]
Subject: Re: ceiling function
Hi Kees,
On Mon, 8 Aug 2011, Straatman, Kees R. (Dr.) wrote:
> Why not floor(x)?
>
> As far as I can see there is no difference in the results. Is there a
> special reason to put -floor(-x)?
Try this:
print(-floor(-5.5));
print(floor(5.5));
In other words, floor(x) rounds down, while -floor(-x) rounds up.
Ciao,
Johannes