Login  Register

Re: ceiling function

Posted by Wes Armour on Aug 07, 2011; 2:56pm
URL: http://imagej.273.s1.nabble.com/ceiling-function-tp3683582p3683592.html

Thanks to you all,

I had been trying...

int_part = parseInt(d2s(delta_t,0));

if( int_part < delta_t) {
     int_part++;
}

So -floor(-x) is far better :)

Cheers,

Wes.
________________________________________
From: ImageJ Interest Group [[hidden email]] on behalf of Gabriel Landini [[hidden email]]
Sent: 07 August 2011 13:56
To: [hidden email]
Subject: Re: ceiling function

On Sunday 07 Aug 2011, Dscho wrote:

> On Sun, 7 Aug 2011, Albert Cardona wrote:
> > 2011/8/7 Wes Armour <[hidden email]>:
> > > I am writing an imagej macro. In it I need to round up to the nearest
> > > integer e.g. 2.1 -> 3 Normally this can be done with the ceiling
> > > function, is there a function like this in imagej macro language??
> > > I've found round and floor, but no ceil.
> >
> > So you could add 1 and then call floor ?
>
> Or -floor(-x).

Yes, that one might be better.  Ceiling as floor(x +1)  does not work for x=0;
it returns 1 instead of 0.

Cheers
Gabriel

--
This e-mail and any attachments may contain confidential, copyright and or privileged material, and are for the use of the intended addressee only. If you are not the intended addressee or an authorised recipient of the addressee please notify us of receipt by returning the e-mail and do not use, copy, retain, distribute or disclose the information in or attached to the e-mail.
Any opinions expressed within this e-mail are those of the individual and not necessarily of Diamond Light Source Ltd.
Diamond Light Source Ltd. cannot guarantee that this e-mail or any attachments are free from viruses and we cannot accept liability for any damage which you may sustain as a result of software viruses which may be transmitted in or with the message.
Diamond Light Source Limited (company no. 4375679). Registered in England and Wales with its registered office at Diamond House, Harwell Science and Innovation Campus, Didcot, Oxfordshire, OX11 0DE, United Kingdom