Computer-scientist functions on HP Prime? Michael O. Tjebben Junior Member Posts: 25 Threads: 5 Joined: Sep 2011 08-21-2013, 07:13 AM I apologize in advance if this topic has already been discussed, but I did not find anything in an hp forum search nor google. Does the HP Prime support computer-scientist logic functions similar to what the HP16C does? Base conversions, logic manipulations, etc? Gilles Carpentier Senior Member Posts: 468 Threads: 17 Joined: May 2011 08-21-2013, 09:32 AM Hello I dont' know exactly what the 16C can do but the Prime manage binary, octal, decimal and hexa integer up to 64 bits, arithmetics, conversion... You can use BITAND BITNOT BITOR BITXOR, BITSL (bitwise shift left) etc. To enter such numbers, on syntax is #1011b // to enter a bin #4357o // to enter octal etc. Edited: 21 Aug 2013, 9:33 a.m. Tim Wessman Posting Freak Posts: 1,278 Threads: 44 Joined: Jul 2007 08-21-2013, 01:31 PM It supports 64 bits signed/unsigned integers. Syntax is basically #:<-><1-64> with everything after the digits being optional. You can set your default base, bitsize and signed state. So #FFFF:-45h would be a 45 bit signed hexadecimal. Also has this little utility for easy editing/viewing/shifting. TW Edited: 21 Aug 2013, 1:36 p.m. Patrice Senior Member Posts: 274 Threads: 23 Joined: Sep 2007 08-21-2013, 03:39 PM Just a detail. The size goes from -63 to 64 where: -63 is signed 64 bits (63 bits + 1 for sign) -15 is signed 16 bits (15 bits + 1 for sign) 64 is UNsigned 64 bits Patrice Senior Member Posts: 274 Threads: 23 Joined: Sep 2007 08-21-2013, 03:51 PM As said the basic functions of the 16C are here but there is still a lot of them missing. But you can create the ones you need by yourself: ```EXPORT BITSET(Word, BitNum) BEGIN LOCAL Tmp; Tmp:= BITSL(SETBITS(#1,GETBITS(Word)), BitNum); RETURN BITOR(Word, Tmp); END; EXPORT BITCLEAR(Word, BitNum) BEGIN LOCAL Tmp; Tmp:= BITSL(SETBITS(#1,GETBITS(Word)), BitNum); RETURN BITAND(Word, BITNOT(Tmp)); END; EXPORT BITTEST(Word, BitNum) BEGIN LOCAL Tmp; Tmp:= BITSL(SETBITS(#1,GETBITS(Word)), BitNum); RETURN (BITAND(Word, Tmp) <> #0); END; EXPORT BIT#(Word) BEGIN LOCAL Tmp, Cnt; Cnt:= 0; WHILE Word <> #0 DO IF BITAND(Word, #1) <> #0 THEN Cnt:= Cnt+1; END; Word:= BITSR(Word,1); END; RETURN Cnt; END; ``` Edited: 21 Aug 2013, 3:52 p.m. Gilles Carpentier Senior Member Posts: 468 Threads: 17 Joined: May 2011 08-21-2013, 04:40 PM Fine ! ;) By the way how do you convert from a base to another ? I do an addition with the first number equal to #0base ex: #0b+#FFh to convert FFh in base2. Is there an integrated command ? Tim Wessman Posting Freak Posts: 1,278 Threads: 44 Joined: Jul 2007 08-21-2013, 04:47 PM SETBASE/GETBASE SETBITS/GETBITS Remember, unlike the 48 series, numerical integers carry along information about signing, size, and base as part of the number. Similar to how numbers can be flagged as HMS. Thus there is no longer HMS+ HMS- and similar. They just work... TW Edited: 21 Aug 2013, 4:56 p.m. Patrice Senior Member Posts: 274 Threads: 23 Joined: Sep 2007 08-21-2013, 05:14 PM Properly speaking, the base conversion is mainly for display purpose. GETBASE return the base of a value SETBASE sets the base of the value for size, it is GETBITS/SETBITS Look at the little functions above, GETBITS/SETBITS are to ensure that the calculus is properly sized with the value used. Joe Horn Member Posts: 153 Threads: 7 Joined: Jun 2008 08-21-2013, 05:58 PM Quote:```EXPORT BIT#(Word) BEGIN LOCAL Tmp, Cnt; Cnt:= 0; WHILE Word <> #0 DO IF BITAND(Word, #1) <> #0 THEN Cnt:= Cnt+1; END; Word:= BITSR(Word,1); END; RETURN Cnt; END; ``` Another way to count the number of 1's in 'x' is` hamdist(x,0) `because the hamming distance between zero and a binary number is the number of 1's in it. Patrice Senior Member Posts: 274 Threads: 23 Joined: Sep 2007 08-21-2013, 07:19 PM TY I learned something today :) looks like I should pay more attention to CAS functions. One can also consider the function as misplaced as it would naturally fit in chapter 28 Basic Integer arithmetic. PS looks like odd() is also a candidate to chapter 28. Edited: 21 Aug 2013, 7:33 p.m. Paul Dale Posting Freak Posts: 3,229 Threads: 42 Joined: Jul 2006 08-21-2013, 08:08 PM I looks like one's complement from the 16C and the 34S aren't there and the extra sign mode of the 34S (sign and magnitude). Does anyone really want these extra two sign modes? What about the carry and overflow flags? - Pauli Michael O. Tjebben Junior Member Posts: 25 Threads: 5 Joined: Sep 2011 08-22-2013, 06:20 PM Thank you to everyone that responded! It appears that the Prime will do what I am interested in doing, but not in a simple, intuitive way like the hp16c can - there is a learning curve and a small bit of study to do for the Prime that was not necessary for the hp16c. In other words, with the hp16c, one can do all of the computer scientist functions without reading a single page of the manual. Of course the HP16C is DEDICATED to such purposes, hence, it is difficult to fault a powerful multi-purpose unit like the Prime, which I will likely purchase simply for the interest in having such a powerful machine, especially as it can interface to data-collection and other devices. I miss some of the fun that I had using and collecting the great set of peripherals and add-ons for the HP-41 collection. -Mike plivesey Junior Member Posts: 10 Threads: 2 Joined: Jul 2013 08-22-2013, 06:59 PM This is undoubtedly me being stupid but I can't seem to get the 'Edit Integer' dialog to appear in RPN mode. In Textbook and Algebraic mode I don't have a problem. Any ideas as to what I'm doing wrong or is this confirmed behaviour? Thanks, Paul « Next Oldest | Next Newest »

 Possibly Related Threads... Thread Author Replies Views Last Post Use 82240B as computer printer R. Pienne 3 1,631 12-09-2013, 12:19 PM Last Post: Marcus von Cube, Germany Prime: Scope of Variable and functions within programs Thomas Chrapkiewicz 9 2,353 11-18-2013, 03:39 PM Last Post: Thomas Chrapkiewicz HP Prime - CAS functions in Spreadsheet App CR Haeger 6 1,645 11-11-2013, 12:37 AM Last Post: Michael de Estrada [41CL] New Extra Functions version Monte Dalrymple 0 783 11-08-2013, 04:32 PM Last Post: Monte Dalrymple HP Prime: in need of help with defining functions Alberto Candel 14 2,842 10-27-2013, 10:48 AM Last Post: Alberto Candel OT: Jeppesen E6B Wind-Easy Computer (Slide Rule) Eddie W. Shore 18 4,558 10-12-2013, 03:26 PM Last Post: George Litauszky HP Prime spreadsheet functions SanS 0 1,467 10-04-2013, 04:23 AM Last Post: SanS Stats functions on the HP34S Nicholas van Stigt 5 1,468 09-24-2013, 02:45 AM Last Post: Nick_S Trig Functions Howard Owen 11 2,584 09-16-2013, 02:53 PM Last Post: Fred Lusk 50g piecewise functions Kurt Fankhauser 6 1,704 09-15-2013, 08:01 PM Last Post: Kurt Fankhauser

Forum Jump: