HP Prime: FLOOR, iPart , and their use in programs

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.
Here is an example. This program below computes the binary expression B of a whole number N as a string of 0's and 1's:

LOCAL B:="";
IF FP(N/2) =0 THEN B:=B+"0";
ELSE B:=B+"1";

This works fine, but if I replace the 8th line with

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.


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.


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.


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.


INT is from the 39gII. IP and INT seem to be synonymous. The same holds for FRAC and FP.


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.


Edited: 1 Dec 2013, 8:34 p.m.


Also, the help for the function "exact" shows instead the function "float2rational" (which is not listed in the catalogue)

Possibly Related Threads…
Thread Author Replies Views Last Post
  Does the HP Prime really compiles the user programs? CompSystems 3 2,665 12-13-2013, 01:55 PM
Last Post: Mike Morrow
  HP Prime: Lists in programs Alberto Candel 7 3,404 12-04-2013, 02:16 AM
Last Post: Alberto Candel
  HP Prime: matrices in programs, in need of help Alberto Candel 9 3,159 11-26-2013, 01:33 AM
Last Post: cyrille de Brébisson
  HP Prime: password protection for programs Davi Ribeiro de Oliveira 2 1,549 11-22-2013, 12:45 PM
Last Post: Geoff Quickfall
  Prime: Scope of Variable and functions within programs Thomas Chrapkiewicz 9 3,224 11-18-2013, 03:39 PM
Last Post: Thomas Chrapkiewicz
  Question about transfering programs to the HP Prime Namir 10 3,267 11-17-2013, 04:01 PM
Last Post: Namir
  [Download] PrimeComm: Alternative small utility to upload/download programs to the HP Prime Erwin Ried 6 2,439 11-17-2013, 10:18 AM
Last Post: Erwin Ried
  HP Prime: do not send programs and shuts down by pressing Apps Davi Ribeiro de Oliveira 1 1,315 11-12-2013, 11:05 AM
Last Post: Joseph Ec
  Grouping programs on the HP Prime Michael de Estrada 11 3,596 11-04-2013, 01:38 PM
Last Post: Damien
  More programs for polar-rectangular conversion on HP Prime Michael de Estrada 4 1,909 11-04-2013, 12:43 AM
Last Post: Michael de Estrada

Forum Jump: