Integer Confusion and : - Printable Version +- HP Forums (https://www.hpmuseum.org/forum) +-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html) +--- Forum: HP Prime (/forum-5.html) +--- Thread: Integer Confusion and : (/thread-7657.html) Integer Confusion and : - KeithB - 01-25-2017 03:54 PM All this talking about random numbers has made me want to port the Marsenne twister to HP-PPL. Most algorithms use bit twiddling and 32 bit integers. Given the "binary explorer" I assume that most numbers are 64 bit. Is there a way to declare a 32 bit variable/number? I see the intriguing ':' operator, but as far as I could tell, it is undocumented. (It was a bit tedious searching the manual for ':' - whoever wrote the manual sure likes his colons!) I also see the SETBITS() command. Can I use that on a variable to make it 32 bits? RE: Integer Confusion and : - Han - 01-25-2017 04:18 PM You can change the integer bits in the settings page. They can be set to signed or unsigned, and the word size can be up to 64 bits. RE: Integer Confusion and : - KeithB - 01-25-2017 04:37 PM Ah, yes, and I see that the default is unsigned, 32 bit which is what I want. Is there anyway to specify that a variable is an integer? RE: Integer Confusion and : - Tim Wessman - 01-25-2017 06:02 PM You cannot force a type on variable (that will restrict anything but that type from being stored in it). #123:32o would be an unsigned, 32 bit integer in octal. #123:-42h would be a signed, 42 bit integer in hex. and so on... RE: Integer Confusion and : - KeithB - 01-25-2017 06:28 PM Ah, that is why you can have a -32 bit integer! I was wondering why the size of the integer was allowed to be negative. RE: Integer Confusion and : - Han - 01-25-2017 07:01 PM (01-25-2017 04:37 PM)KeithB Wrote:  Ah, yes, and I see that the default is unsigned, 32 bit which is what I want. Is there anyway to specify that a variable is an integer? Not really, but there are R->B and B->R commands to switch between real numbers and "integer" types. RE: Integer Confusion and : - mark4flies - 01-26-2017 01:30 AM 1 + For better RNG. Everybody benefits at low cost. Please consider it. RE: Integer Confusion and : - cyrille de brĂ©bisson - 01-26-2017 06:53 AM Hello, If you are planning to work with integers in a program, remember that you can access integers bits using the () syntax as in: LOCAL a:= #12345h; a(x) to get/set the xth bit in the integer and that a(x,y) will allow you to set/get the y bits at pos x in the integer. Cyrille RE: Integer Confusion and : - KeithB - 01-26-2017 05:03 PM Thanks. Hard to remember when it is not documented! 8^) Also, I found that it is much better to work with Lists than Matrices. Lists will store integers, Matrices don't.