List Commands Library for 50g

08262017, 06:59 PM
Post: #99




RE: List Commands Library for 50g
(08262017 05:32 PM)pier4r Wrote: I actually don't know why GET and SUB would work with reals with decimal part. It can surely produce some nice "tricks" but looks dirty in my opinion. I doubt it was by design, and more likely just a consequence of how a particular SysRPL command works (COERCE). After looking at a couple of the builtin routines, it appears that they used COERCE to convert the given number into what is referred to as a "System Binary" (or BINT), which is what most internal routines use when integers are in context. COERCE can be thought of as "move the given real to its closest BINT counterpart", which of course implies the rounding which happens. BINTs are unsigned, so the closest BINT to a negative real is 0. BINTs are only 5 nibbles, so the maximum real (integer) that can be represented is (2^201) or 1048575, which is represented by a BINT with the hex digits FFFFF. Any greater value real is "pinned" to that BINT in the same way that negative reals all convert to 0. I tested SUB a little further and was reminded of something else I had forgotten, which is that it is very "forgiving" of outofbounds indices. This is actually documented in the fine print of the AUR for SUB, which states "Values of n less than 1 are treated as 1; values of n exceeding the length of the string or list are treated as that length." So there's already precedent for inconsistencies in how indices are treated with the builtin commands. GET definitely doesn't work that way. Example: if you execute Code: "ABC" 2.3 999 SUB Likewise, Code: "ABC" 1.2 20.8 SUB 

« Next Oldest  Next Newest »

User(s) browsing this thread: 1 Guest(s)