Search this board for IEEE754 for the long way in blocks.
float.htm
<!DOCTYPE html>
<html>
<head>
<title>Hexadecimal to Float Conversion</title>
</head>
<body>
<p>Hexadecimal number: 450B9AB0</p>
<p>Float number (Big Endian): <span id="floatValue"></span></p>
<script>
// Convert hexadecimal to float in Big Endian format
const hex = "450B9AB0";
const binary = parseInt(hex, 16).toString(2).padStart(32, '0');
const sign = binary[0] === '1' ? -1 : 1;
const exponent = parseInt(binary.substring(1, 9), 2) - 127;
const mantissa = 1 + parseInt(binary.substring(9), 2) / Math.pow(2, 23);
const floatValue = sign * mantissa * Math.pow(2, exponent);
// Display the result on the HTML page
document.getElementById("floatValue").innerHTML = floatValue.toFixed(3);
</script>
</body>
</html>
from GPT-3.5
could be the solution, i try to turn it into blocks (if i succeed)
thank you very much
Are you sending this data from your device? Are you downloading from the server? Can you modify the floating point encoding?
I receive data from a PV inverter via local network and unfortunately I can't change anything.
i already made a working device written in c for esp8266
now I wanted to make a tablet version
I didn't understand this...
I guess it refers to your script from the previous post.
Actually I receive every 10 seconds a json string, production, consumption, battery in/out, power grid in/out, battery %status.
therefore the values to be converted are many and all in hexadecimal (8 bytes).
I was thinking of creating a procedure with return value and passing the desired hex value.
How is your json string?
Separate each element from your json and convert it to float with the code from the example above.
I will consider your solution but since I'm learning, I want to try to build the block procedure based on your script, I've already started and I hope to succeed.
I will let you know
thank you with all my heart
after some adjustments, this is the final result.
Thanks again for the help
p.s.
Can you explain better how to implement your solution, it could be useful for me in the future
- do I have to create a webserver?
- how do I pass the value to convert?
But you are using Kodular for coding, please ask in Kodular community.
NO, I had started with Kodular and then ported everything to AI2, a member of the Kodular forum suggested a discussion on AI2 so I had to thank him.
HI
then show the blocks in App Inventor.
Have you seen the previous example borrar_float_ver_2.aia (2.0 KB)?
Here you have another version, I have put the result in two ways with the value variable and with the float variable.
borrar_float_v3.aia (2.4 KB)
if i press the button nothing happens, not even changing the hex string
It works for me. What version of Android are you using?