PRINT and how it displays floats

Be clear with the topic titles to help members find the answers
Post Reply
amenjet
Posts: 301
Joined: Tue Jan 03, 2023 7:54 pm

PRINT and how it displays floats

Post by amenjet »

Whilst working on the new OPL, I wondered how floats were displayed, more specifically, when does the display flip to mantissa plus exponent.
A short program:

Code: Select all

TEST:
LOCAL A,B,C,I%

I%=1
B=1
DO

A = 123.456789123
B = B*10
C = A *B
PRINT C

GET
I%=I%+1
UNTIL I%>20
Output:

Code: Select all

1234.56789123
12345.6789123
123456.789123
1234567.89123
12345678.9123
123456789.123
1234567891.23
12345678912.3
123456789123
1234567891230
12345678912300
123456789123000
1234567891230000
12345678912300000
123456789123000000
123456789123E+18
123456789123E+19

When run, you can see that the integer display format is used even when the number displayed is longer than the mantissa/exponent format, which I found a bit odd. has anyone seen a description of how floats are displayed anywhere in a manual?
MartinP
Posts: 54
Joined: Wed Jan 04, 2023 7:51 pm

Re: PRINT and how it displays floats

Post by MartinP »

Interesting to see. I guess the writers of OPL didn't care too much about this because they had it covered by GEN$() or SCI$().
https://www.jaapsch.net/psion/manlzpg.htm#GEN_
Note that CALC is better and swaps to exponent form when one line of the screen is full.
User avatar
Martin
Global Admin
Posts: 296
Joined: Mon Jan 02, 2023 5:18 pm

Re: PRINT and how it displays floats

Post by Martin »

That's interesting especially the way it pads out with zeros upto 18 digits. The Calculator (XP & LZ) stops at 15 before converting to exponent - probably because of the screen limits.

Andrew you will know this but for others watching... Page 106 of the republished technical reference manual. The Maths functions section has a floating-point number section.

When working in OPL I never trusted the Organiser to display numbers correctly and always use the FIX$ function. This way I can place it exactly where I want it on the screen.

Interesting that you are working on your 'new' opl. Do you think it will 'port' to other platforms? Andriod? If I could run OPL on a mobile phone then I might buy one.

Sincerely
Martin
amenjet
Posts: 301
Joined: Tue Jan 03, 2023 7:54 pm

Re: PRINT and how it displays floats

Post by amenjet »

MartinP wrote: Mon Jun 03, 2024 9:46 am Interesting to see. I guess the writers of OPL didn't care too much about this because they had it covered by GEN$() or SCI$().
https://www.jaapsch.net/psion/manlzpg.htm#GEN_
Note that CALC is better and swaps to exponent form when one line of the screen is full.
Hmm, interesting, as that implies the number display code is different between the calculator and OPL. I'm surprised they didn't re-use code considering how ROM space is limited.
There's also only 12 digits in a FLOAT, so any digits after that are just zeros.
amenjet
Posts: 301
Joined: Tue Jan 03, 2023 7:54 pm

Re: PRINT and how it displays floats

Post by amenjet »

Martin wrote: Mon Jun 03, 2024 10:17 am That's interesting especially the way it pads out with zeros upto 18 digits. The Calculator (XP & LZ) stops at 15 before converting to exponent - probably because of the screen limits.

Andrew you will know this but for others watching... Page 106 of the republished technical reference manual. The Maths functions section has a floating-point number section.

When working in OPL I never trusted the Organiser to display numbers correctly and always use the FIX$ function. This way I can place it exactly where I want it on the screen.

Interesting that you are working on your 'new' opl. Do you think it will 'port' to other platforms? Andriod? If I could run OPL on a mobile phone then I might buy one.

Sincerely
Martin
Don't get too excited, there's a long way to go before anything very useful is going to appear. It is written in C, though, as I want to run it on the Pico and recreation, so it should port to anything with C available. That is almost anything, really. Android is java based, though, although I think there's a framework for C, I think. Well, maybe. On a phone you also have a lot of graphical infrastructure to put together.
Post Reply