Floating Point and other Conversions

So I was going to make an app to translate different coding languages, like UTF-8, UTF-16, IP Address, Floating Point, RGB, Boolean, but a function for conversions don’t exist. The method of making those conversion require some code to be made and a good understanding with translating each code language between eachother. If there was a button that could translate between 2 of those for example: Floating Point -> Hexidecimal, Boolean -> IP Address, Decimal -> UTF-8/16, then it would make conversions alot better to handle.

That's the fun of learning how to program in App Inventor.

A number of conversions are available


2 posts were merged into an existing topic: Converting values in mit app inventor

I receive data in hexadecimal format (8 bytes) and I would like to convert it to float but I can't.
example (real) 0x450B9AB0 = 2233.67
I ask for help

From your example string, in javascript:


I also get that result but it's wrong because it's an INT while I need a FLOAT
Floating Point to Hex Converter (gregstoll.com)

Search this board for IEEE754 for the long way in blocks.


<!DOCTYPE html>
	<title>Hexadecimal to Float Conversion</title>
	<p>Hexadecimal number: 450B9AB0</p>
	<p>Float number (Big Endian): <span id="floatValue"></span></p>

		// 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);

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

borrar_float.aia (2.3 KB)


borrar_float_ver_2.aia (2.0 KB)

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

I hope it can help someone

after some adjustments, this is the final result.
Thanks again for the help
Can you explain better how to implement your solution, it could be useful for me in the future

But you are using Kodular for coding, please ask in Kodular community.