Hello everyone. I have a LZ and I think it has a bug in the calculator application. When I enter SQR(5*5) it should return 5. Instead it gives me 5.000000002
Has anyone else noticed this? Is it a known bug?
Thanks.
LZ calculator bug?
- Martin
- Global Admin
- Posts: 284
- Joined: Mon Jan 02, 2023 5:18 pm
LZ calculator bug
Hi Guy and welcome
The Technical Reference Manual (here) - put together by enthusiasts, you will notice the sources listed on page 2 - has release notes for all the Model and ROM variants.. (Page 9 for example)
If you don't find anything listed there and after other members have read the post, we might have to add it... I'll let you decide the best place to put it!
Sincerely
Martin
PS Users are reminded to check the revision reference on the front cover.
The Technical Reference Manual (here) - put together by enthusiasts, you will notice the sources listed on page 2 - has release notes for all the Model and ROM variants.. (Page 9 for example)
If you don't find anything listed there and after other members have read the post, we might have to add it... I'll let you decide the best place to put it!
Sincerely
Martin
PS Users are reminded to check the revision reference on the front cover.
-
- Posts: 285
- Joined: Tue Jan 03, 2023 7:54 pm
Re: LZ calculator bug?
I'm not certain but I suspect this is due to rounding errors. The root of 5 cannot be held with total accuracy in the bits used by the Psion. So, when you square the rounded value it isn't possible for the result to be 5 as the numbers being multiplied aren't exactly root 5.
That's my guess
-
- Posts: 77
- Joined: Tue Jan 03, 2023 10:03 pm
Re: LZ calculator bug?
It happens with other numbers too, also on LZ64 and XP, so I don’t think it is a bug but as Andrew said more likely a rounding limitation.
- Martin
- Global Admin
- Posts: 284
- Joined: Mon Jan 02, 2023 5:18 pm
LZ calculator bug - even more examples
Although I don't understand the implications, here is a bit more on this..
In our example SQR(5*5) the CALCulator displays the results to 11 decimal places. 5.00000000002 (REF 1 below)
Try this SQR(5*5)+1 for 6.00000000002
Then SQR(5*5)+10 for 15
or FIX the decimal places
FIX=12 then 5.000000000020
FIX=10 gives 5.0000000000
Out of interest you get the same results in OPL
try this
Interesting!
Martin
[EDIT] PS I checked the pocket spreadsheet... can't be sure the rounding error is here or not as it only displays 10 decimal places... Notice It is a spreadsheet function SQRT()
. . .
[Another EDIT]
this Organiser Rounding Error even made it to the Developer Emulator..
. . .
[Final EDIT (I promise)]
Guy you've really put the cat amongst the pigeons with this one... it's everywhere..
. .
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
REF 1 Page 32 of the republished Operating Manual
Do the calculation 4*7/9. Notice that the result 3.11111111111 is displayed with 11 decimal places. This is how the calculator normally works - allowing as many significant digits as will fit in a total of 12 figures
In our example SQR(5*5) the CALCulator displays the results to 11 decimal places. 5.00000000002 (REF 1 below)
Try this SQR(5*5)+1 for 6.00000000002
Then SQR(5*5)+10 for 15
or FIX the decimal places
FIX=12 then 5.000000000020
FIX=10 gives 5.0000000000
Out of interest you get the same results in OPL
try this
Code: Select all
TEST:
LOCAL I
DO
PRINT I,SQR(I*I)
GET
I=I+1
UNTIL I>10
Then try changing the PRINT statement to PRINT I,SQR(I*I)+(I)
Martin
[EDIT] PS I checked the pocket spreadsheet... can't be sure the rounding error is here or not as it only displays 10 decimal places... Notice It is a spreadsheet function SQRT()
. . .
[Another EDIT]
this Organiser Rounding Error even made it to the Developer Emulator..
. . .
[Final EDIT (I promise)]
Guy you've really put the cat amongst the pigeons with this one... it's everywhere..
. .
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
REF 1 Page 32 of the republished Operating Manual
Do the calculation 4*7/9. Notice that the result 3.11111111111 is displayed with 11 decimal places. This is how the calculator normally works - allowing as many significant digits as will fit in a total of 12 figures
You do not have the required permissions to view the files attached to this post.
-
- Posts: 285
- Joined: Tue Jan 03, 2023 7:54 pm
Re: LZ calculator bug?
The calculator uses the opl arithmetic engine, so results should be identical.
-
- Posts: 34
- Joined: Wed Jan 04, 2023 2:08 pm
Re: LZ calculator bug?
Out of interest I used the calculator and OPL program on the Psion 3 and it correctly produced 5, so the bug does not follow onto later models. The Psion 3's hinges have gone and it's falling to bits though so I'll continue to use the Org 2.
-
- Posts: 3
- Joined: Wed Sep 04, 2024 8:44 pm
Re: LZ calculator bug?
Thanks to everyone for the replies. I don't think it's a rounding error though, because SQR(25) gives the same as SQR{5*5). Remarkable that this bug never surfaced until now. At least I couldn't find anything about it on the internet.
- Martin
- Global Admin
- Posts: 284
- Joined: Mon Jan 02, 2023 5:18 pm
Found it!
I knew I had seen it somewhere... Boris (RIP) discuses what could be a bug in this thread on his Original Forum (here).
You will notice a discussion about 'precedence' and only a passing mention of the 'rounding error'
By the way the contributors Nick and Raymond are both members here..
Sincerely Martin
You do not have the required permissions to view the files attached to this post.
-
- Posts: 13
- Joined: Tue Sep 03, 2024 12:06 pm
Re: LZ calculator bug?
Organiser 1 with Utility Pack
5
Not even a decimal point, no difference for SQRT(5*5) or SQRT(5)
So looks like the Maths Pack code for the Organiser 1 is good for that expression form.
My guess is the ROM space limited, so a stripped down algorithm is applied in some ROMs.
When I was writing code for these things, I am reminded now, we wrote quite a few of our own routines to obviate such errors on the Organiser II models. The math performed being sensitive to such rounding artifacts.
Hope you like the retro device picture...
5
Not even a decimal point, no difference for SQRT(5*5) or SQRT(5)
So looks like the Maths Pack code for the Organiser 1 is good for that expression form.
My guess is the ROM space limited, so a stripped down algorithm is applied in some ROMs.
When I was writing code for these things, I am reminded now, we wrote quite a few of our own routines to obviate such errors on the Organiser II models. The math performed being sensitive to such rounding artifacts.
Hope you like the retro device picture...
You do not have the required permissions to view the files attached to this post.