(32S) Floor Function
|
06-03-2017, 07:47 AM
(This post was last modified: 06-15-2017 01:25 PM by Gene.)
Post: #1
|
|||
|
|||
(32S) Floor Function
For real input the programme returns Floor of input without disturbing the stack.
Improvements most welcome. Code:
|
|||
06-29-2017, 04:02 PM
Post: #2
|
|||
|
|||
RE: (32S) Floor Function | |||
06-30-2017, 07:05 AM
Post: #3
|
|||
|
|||
RE: (32S) Floor Function
Doesn't work for -0.999999999999 (-1 + 1e-12), or in general for
-9.9999999999x Eyyy, x=5..9, yyy>=-1 (both the 32S and 42S versions, BTW) The easiest way without stack preservation is Code: >LBL "FLOOR" I don't have a 32S so I don't know what commands are available there. For the 41/42S, one version with stack preservation is as follows: Code: >LBL"FLOOR" Cheers, Werner 41CV†,42S,48GX,49G,DM42,DM41X,17BII,15CE,DM15L,12C,16CE |
|||
06-30-2017, 07:23 AM
Post: #4
|
|||
|
|||
RE: (32S) Floor Function | |||
06-30-2017, 08:51 AM
Post: #5
|
|||
|
|||
RE: (32S) Floor Function
I'm sure ;-)
Free42 and DM42 work with 34 digits, so there, take (-1 + 1e-34) Werner 41CV†,42S,48GX,49G,DM42,DM41X,17BII,15CE,DM15L,12C,16CE |
|||
06-30-2017, 11:31 AM
(This post was last modified: 06-30-2017 11:31 AM by c785.)
Post: #6
|
|||
|
|||
RE: (32S) Floor Function
OK, you're right. "IP" after "+" isn't a good idea, so replace the sequence
Code: + Code: X<>Y |
|||
06-30-2017, 02:58 PM
Post: #7
|
|||
|
|||
RE: (32S) Floor Function
OK, I think I got the idea now. How about this:
Code: > LBL "FLOOR" |
|||
07-01-2017, 10:16 AM
Post: #8
|
|||
|
|||
RE: (32S) Floor Function
LastX is not correct ;-) In my version above, it is.
Werner 41CV†,42S,48GX,49G,DM42,DM41X,17BII,15CE,DM15L,12C,16CE |
|||
07-02-2017, 09:29 AM
Post: #9
|
|||
|
|||
RE: (32S) Floor Function
You're right once again. The only thing I'd do differently is the "nop" command -- a label there is quite misleading and can lead to trouble when the code is part of a larger program, so I prefer "X<>X" in its place.
In any case, RPN is great. What I could have done with RPL in about five minutes now took me several days to grasp. But I did learn a thing or two. |
|||
07-02-2017, 10:18 AM
Post: #10
|
|||
|
|||
RE: (32S) Floor Function
X<> ST X is two bytes, and I have a label there for the CEIL function to jump to ;-)
Code: { 38-Byte Prgm } Cheers, Werner 41CV†,42S,48GX,49G,DM42,DM41X,17BII,15CE,DM15L,12C,16CE |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 2 Guest(s)