HP Prime: FLOOR, iPart , and their use in programs - Printable Version +- HP Forums (https://archived.hpcalc.org/museumforum) +-- Forum: HP Museum Forums (https://archived.hpcalc.org/museumforum/forum-1.html) +--- Forum: Old HP Forum Archives (https://archived.hpcalc.org/museumforum/forum-2.html) +--- Thread: HP Prime: FLOOR, iPart , and their use in programs (/thread-257436.html) |
HP Prime: FLOOR, iPart , and their use in programs - Alberto Candel - 12-01-2013 Good Morning, The standard use for FLOOR(x) is the greatest integer less than or equal to x. I usually denote that by [x] (since Gauss), and call it "integer part." This terminology is standard in math, but not so much in comp sci. The function iPart(x) is related to FLOOR(x) by iPart(x)=FLOOR(x) if FLOOR(x) > or = 0, and FLOOR(x)+1 otherwise. (So iPart is not the integer part, but what remains after droping everything to the right of the decimal point.) This is what the Help documentation in the Prime states, but not what it actually uses: in the Prime FLOOR(x) and iPart(x) seem to be the same thing: iPart(-1.23) returns -2, but it should return -1.
Using these function in a program brings up some serious trouble.
EXPORT Bin(N)
This works fine, but if I replace the 8th line with N:=iPart(N/2);I get "Bin Error: Bad argument type." The Debug feature in Program does not really help much (and is mostly undocumented in the user guide). I hope that you can replicate this, and if so, fix it!
Edited: 1 Dec 2013, 1:22 p.m.
Re: HP Prime: FLOOR, iPart , and their use in programs - Marcus von Cube, Germany - 12-01-2013 I assume that iPart is the CAS variant of FLOOR. There are some recent discussions here about the proper use of CAS functions in programs. I guess you are looking for INT instead.
Re: HP Prime: FLOOR, iPart , and their use in programs - Alberto Candel - 12-01-2013 I am not sure I understand. In the catalogue there is no INT, there is int but that is for integrals. Regardless, the Help for iPart is incorrect; it does not describe what iPart actually does.
[added] there is IP, problaby what you meant by INT [/added] Edited: 1 Dec 2013, 1:40 p.m.
Re: HP Prime: FLOOR, iPart , and their use in programs - Alberto Candel - 12-01-2013 My program works with IP. The usage of iPart and error may be related to iPart being a real number, while IP is an integer. Thanks.
Re: HP Prime: FLOOR, iPart , and their use in programs - Marcus von Cube, Germany - 12-01-2013 INT is from the 39gII. IP and INT seem to be synonymous. The same holds for FRAC and FP.
Re: HP Prime: FLOOR, iPart , and their use in programs - Tim Wessman - 12-01-2013 Just a heads up - That was a mistake that will be going away very shortly. Basically, having INT and FRAC for the integer part and fractional parts works fine *until* you have the ability to do integration. Then it gets very confusing. Thus the commands where renamed as IP and FP to follow the 48 series naming. However, there was an entry for INT and FRAC to call the ipart/fpart command leftover in the depths of the CAS that was not noticed until after first shipping release. The next update will have that removed to avoid confusion. TW
Edited: 1 Dec 2013, 8:34 p.m.
Re: HP Prime: FLOOR, iPart , and their use in programs - Alberto Candel - 12-01-2013 Also, the help for the function "exact" shows instead the function "float2rational" (which is not listed in the catalogue)
|