![]() |
Forum Index : Microcontroller and PC projects : PEEK and POKE FLOAT var! 32 bit
Author | Message | ||||
TassyJim![]() Guru ![]() Joined: 07/08/2011 Location: AustraliaPosts: 6266 |
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: AustraliaPosts: 999 |
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 KingdomPosts: 4032 |
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: AustraliaPosts: 6266 |
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: AustraliaPosts: 6266 |
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 |
||||
![]() |
![]() |
The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |