RPN FLOOR and CEIL Message #1 Posted by Werner on 27 Sept 2011, 5:37 a.m.
easy, short, no tests, valid for positive and negative arguments
1.using only FRC
CEIL(x) = x  FRC(FRC(x)  1)
FLOOR(x) = x  FRC(FRC(x) + 1)
(written 41C style, but easily portable)
*LBL"CEIL"
ENTER
FRC
1

FRC

RTN
*LBL"FLOOR"
ENTER
FRC
1
+
FRC

RTN
2.using MOD: (1 byte shorter for FLOOR..)
*LBL"CEIL"
RCL X (or ENTER ENTER)
1
MOD

RTN
*LBL"FLOOR"
RCL X
1
MOD

RTN
Cheers, Werner
