Kind of "overflow" in integers

Discussion around the SwissMicros DM42 calculator
Boub65
Posts: 231
Joined: Tue Sep 12, 2017 4:34 pm
Location: Rabat, Morocco

Kind of "overflow" in integers

Post by Boub65 »

Hello all,
I am doing some "big integers" algorithms and I am looking for a way to detect if an operation went from "integer" to "float", and so lost its precision.

I know that I can always check if result is bigger than 1E34 (or something like this).

Any flag or way to detect if a register is an integer or a float number (or "went from" during an operation)?

Thanks,
Sincerely,
Boubker.
Sincèrement, Sincerely, 73,
Boubker

DM15L, DM41L, DM42 #00855 (domes upgraded), DM41X #00707
HP48SX (with dark screen), HP42s, HP32SII (1990 with fraction bug), HP41C/CV
TI-89 titanium, CASIO fx-cg50 and Numworks (to play with micropython)
Thomas Okken
Posts: 1100
Joined: Tue May 02, 2017 5:48 pm
Location: Netherlands
Contact:

Re: Kind of "overflow" in integers

Post by Thomas Okken »

The calculator does not keep track of whether numbers are exact or not, so making sure that your results (and all intermediates) are less than 1e34 is the only way to be sure.
Boub65
Posts: 231
Joined: Tue Sep 12, 2017 4:34 pm
Location: Rabat, Morocco

Re: Kind of "overflow" in integers

Post by Boub65 »

Thanks Thomas for your reply,
is it also the reason we don't have "binary" operations in Free42 (AND OR >> << etc...)?
Sincèrement, Sincerely, 73,
Boubker

DM15L, DM41L, DM42 #00855 (domes upgraded), DM41X #00707
HP48SX (with dark screen), HP42s, HP32SII (1990 with fraction bug), HP41C/CV
TI-89 titanium, CASIO fx-cg50 and Numworks (to play with micropython)
grsbanks
Posts: 1122
Joined: Tue Apr 25, 2017 11:23 am
Location: Preston, Lancs, UK
Contact:

Re: Kind of "overflow" in integers

Post by grsbanks »

Boub65 wrote:
Thu Dec 31, 2020 11:13 am
is it also the reason we don't have "binary" operations in Free42 (AND OR >> << etc...)?
The shift operators are not there but AND, OR, XOR and NOT most certainly are. They're in the BASE > LOGIC menu. See p249-250 of the manual.
There are only 10 kinds of people in the world: those who understand binary and those who do not.
Boub65
Posts: 231
Joined: Tue Sep 12, 2017 4:34 pm
Location: Rabat, Morocco

Re: Kind of "overflow" in integers

Post by Boub65 »

grsbanks wrote:
Thu Dec 31, 2020 2:08 pm
The shift operators are not there but AND, OR, XOR and NOT most certainly are. They're in the BASE > LOGIC menu. See p249-250 of the manual.
Thanks @grsbanks
But I suppose that these functions only work on 36bits integers and not the full 34 digits integers...

Example you can only convert 2^35-1 in binary, every thing greater gives a <too big> error...

EDIT: in fact all the BASE menu is limited to 36bits operations even in DECM, wierd when 1) you have all the memory/computing power and 2) that free42 went to 34 digits precision...
Sincèrement, Sincerely, 73,
Boubker

DM15L, DM41L, DM42 #00855 (domes upgraded), DM41X #00707
HP48SX (with dark screen), HP42s, HP32SII (1990 with fraction bug), HP41C/CV
TI-89 titanium, CASIO fx-cg50 and Numworks (to play with micropython)
User avatar
Walter
Posts: 3070
Joined: Tue May 02, 2017 11:13 am
Location: On a mission close to DRS, Germany

Re: Kind of "overflow" in integers

Post by Walter »

Just FYI, you can use the WP43S for integers up to 64bits with the full function set you may know from the HP-16C (DM16) or the WP34S.
WP43 SN00000, 34S, and 31S for obvious reasons; HP-35, 45, ..., 35S, 15CE, DM16L S/N# 00093, DM42β SN:00041
Boub65
Posts: 231
Joined: Tue Sep 12, 2017 4:34 pm
Location: Rabat, Morocco

Re: Kind of "overflow" in integers

Post by Boub65 »

Walter wrote:
Thu Dec 31, 2020 3:36 pm
Just FYI, you can use the WP43S for integers up to 64bits with the full function set you may know from the HP-16C (DM16) or the WP34S.
Thanks @Walter, I know and I will try.
Sincèrement, Sincerely, 73,
Boubker

DM15L, DM41L, DM42 #00855 (domes upgraded), DM41X #00707
HP48SX (with dark screen), HP42s, HP32SII (1990 with fraction bug), HP41C/CV
TI-89 titanium, CASIO fx-cg50 and Numworks (to play with micropython)
grsbanks
Posts: 1122
Joined: Tue Apr 25, 2017 11:23 am
Location: Preston, Lancs, UK
Contact:

Re: Kind of "overflow" in integers

Post by grsbanks »

Boub65 wrote:
Thu Dec 31, 2020 3:11 pm
But I suppose that these functions only work on 36bits integers and not the full 34 digits integers...
They work on numbers of whatever word size is in effect (anything up to 64 bits) on Free42 and consequently on the DM42. The original HP42S is indeed limited to 36 bits only.
There are only 10 kinds of people in the world: those who understand binary and those who do not.
Boub65
Posts: 231
Joined: Tue Sep 12, 2017 4:34 pm
Location: Rabat, Morocco

Re: Kind of "overflow" in integers

Post by Boub65 »

grsbanks wrote:
Thu Dec 31, 2020 4:23 pm
They work on numbers of whatever word size is in effect (anything up to 64 bits) on Free42 and consequently on the DM42. The original HP42S is indeed limited to 36 bits only.
Sorry @grsbank to contradict you on this very end of the year 2020 😜...
...but if you do (2^35+1 AND 1)
2
ENTER
35
Y^X
1
+
1
XEQ "AND"

You get an error: "invalid data"...

But it works with 2^34+1 AND 1 🤔

En cette fin d'année je vous souhaite mes meilleurs voeux à tous et à vos bien-aimés pour la nouvelle année ❤
Last edited by Boub65 on Thu Dec 31, 2020 10:18 pm, edited 1 time in total.
Sincèrement, Sincerely, 73,
Boubker

DM15L, DM41L, DM42 #00855 (domes upgraded), DM41X #00707
HP48SX (with dark screen), HP42s, HP32SII (1990 with fraction bug), HP41C/CV
TI-89 titanium, CASIO fx-cg50 and Numworks (to play with micropython)
grsbanks
Posts: 1122
Joined: Tue Apr 25, 2017 11:23 am
Location: Preston, Lancs, UK
Contact:

Re: Kind of "overflow" in integers

Post by grsbanks »

Did you set the word size to something greater than 36 bits?
There are only 10 kinds of people in the world: those who understand binary and those who do not.
Post Reply