Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 02:52 02 Jul 2025 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : PEEK and POKE FLOAT var! 32 bit

Author Message
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6266
Posted: 07:39am 20 Jun 2025
Copy link to clipboard 
Print this post

Both PEEK and POKE FLOAT var! are described in the Picomite manual as 32bit but they both appear to be 64 bit.

The manual needs updating.

I have a use for 32bit PEEK/POKE FLOAT.

I have written a function for PEEK and will try POKE next but I was wondering if there is a 32bit version lurking in the firmware somewhere.

Jim
VK7JH
MMedit
 
disco4now

Guru

Joined: 18/12/2014
Location: Australia
Posts: 999
Posted: 10:37am 20 Jun 2025
Copy link to clipboard 
Print this post

Not sure if this is what you are doing.
Is this any help
Gerry
Latest F4 Latest H7 FotS
 
JohnS
Guru

Joined: 18/11/2011
Location: United Kingdom
Posts: 4032
Posted: 10:59am 20 Jun 2025
Copy link to clipboard 
Print this post

Something like: convert to 32-bit then use POKE WORD.

Worst case, extract 4 bytes & use POKE BYTE.

John
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6266
Posted: 10:47pm 20 Jun 2025
Copy link to clipboard 
Print this post

Thank Gerry, that should be useful.
I have a routine to read *.OPT files and there are 2 floats in the structure.
This is what I came up with:
   CASE "float"
     b1%= ASC(INPUT$(1,#3)) : b2%= ASC(INPUT$(1,#3)) :b3%= ASC(INPUT$(1,#3)) :b4%= ASC(INPUT$(1,#3))
     tempint% = ((b4%*256+b3%)*256+b2%)*256+b1%
     mantissa = tempint% AND &h7FFFFF
     mantissa = mantissa +&h800000
     exponent = (tempint% >>23)AND &hFF
     exponent = exponent - 127
     sign = (tempint% >>31)AND 1
     tempfloat! = mantissa*2^-23*2^exponent * 10000 ' multiply by 10k to match OPTION LIST
     IF sign THEN tempfloat!=0-tempfloat!
     readdata$ = STR$(INT(tempfloat!))+" ("+STR$(b1%)+" "+STR$(b2%)+" "+STR$(b3%)+" "+STR$(b4%)+")"

I didn't think of converting to 64bit at the bit level.

Jim
VK7JH
MMedit
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6266
Posted: 07:31am 22 Jun 2025
Copy link to clipboard 
Print this post

One interesting issue I found was
2^exponent

In the third last line it was overflowing with large numbers even though the result was going into a float.
I changed it to
2.0^exponent

to force a float and all was well
I ended up using a combination of this code and the FoTS code

Jim
VK7JH
MMedit
 
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025