[Thread Prev][Thread Next][Index]

Re: [ferret_users] ceil, floor, and round



Hi Andrew,

| let floor_a = int(a) - (a LT 0 AND int(a) NE a)
| let ceil_a  = int(a) + (a GT 0 AND int(a) NE a)
| let round_a = int(a-.5+(a GE 0))

Cool.  When I said my formulae were tedious, I was
expecting somebody would come up with more concise
solutions like yours than mine.

To those who aren't familiar with Boolean (conditional)
expressions mixed with arithmetics, a Boolean
expression in Ferret returns 1 if it is "true"
and 0 if "false":  For example,

   3 GT 0  !--> evaluates to 1 because it's true.
   3 GT 8  !--> evaluates to 0 because it's false.

Some computer languages behave like this, but
I didn't know Ferret is one of them, until Andrew
showed it.

Regards,
Ryo


[Thread Prev][Thread Next][Index]

Contact Us
Dept of Commerce / NOAA / OAR / PMEL / TMAP

Privacy Policy | Disclaimer | Accessibility Statement