Kind of "overflow" in integers

Discussion around the Swiss Micros DM42 calculator.
Boub65
Posts: 116
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.
2xDM15L, DM41L, DM42 SN#00855 (+one lost during shipping), DM41X #00707
TI-89 titanium, CASIO fx-cg50 (to play with micropython)

There are three kinds of people in the world: those who know math and those who don't.
Thomas Okken
Posts: 802
Joined: Tue May 02, 2017 5:48 pm
Location: United States
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: 116
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...)?
2xDM15L, DM41L, DM42 SN#00855 (+one lost during shipping), DM41X #00707
TI-89 titanium, CASIO fx-cg50 (to play with micropython)

There are three kinds of people in the world: those who know math and those who don't.
grsbanks
Posts: 1071
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: 116
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...
2xDM15L, DM41L, DM42 SN#00855 (+one lost during shipping), DM41X #00707
TI-89 titanium, CASIO fx-cg50 (to play with micropython)

There are three kinds of people in the world: those who know math and those who don't.
User avatar
Walter
Posts: 1724
Joined: Tue May 02, 2017 11:13 am
Location: Close to FRA, 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.
DM42 SN: 00041 β
WP 43S running on this device

HP-35, HP-45, ..., HP-35S, WP 34S, WP 31S, DM16L
Boub65
Posts: 116
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.
2xDM15L, DM41L, DM42 SN#00855 (+one lost during shipping), DM41X #00707
TI-89 titanium, CASIO fx-cg50 (to play with micropython)

There are three kinds of people in the world: those who know math and those who don't.
grsbanks
Posts: 1071
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: 116
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.
2xDM15L, DM41L, DM42 SN#00855 (+one lost during shipping), DM41X #00707
TI-89 titanium, CASIO fx-cg50 (to play with micropython)

There are three kinds of people in the world: those who know math and those who don't.
grsbanks
Posts: 1071
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