Floating Point and other Conversions

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.

then show the blocks in App Inventor.


1 Like

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?

I confirm it works fine.

I believe you
an older tablet v4.4.2
I wanted to use it for this project not to throw it away.
so all I have left is the block versions.
Now I try on my mobile

I agree, it works on mobile.
alternative solution?
does a javascript runtime exist?

Did it work for you on the Tablet with v4.4.2, the example with the javascript in the asset?

borrar_float.aia (2.3 KB)

it does not work

Does this example work for you with an extension?

on the smartphone yes
unfortunately not on the tablet, the result is always zero

Perhaps try with CustomWebView ?

Runtime Error

Error from Companion: make: no method named `' in class com.sunny.CustomWebView.CustomWebView

on the smartphone it is ok

You may have to use a server side solution, if client side will not work on 4.4.2

With the help of GPT-3.5 you can build an extension...

com.KIO4_HexToDec.aix (6.1 KB)


package com.KIO4_HexToDec;
//  Juan Antonio Villalpando - kio4.com

import com.google.appinventor.components.annotations.DesignerComponent;
import com.google.appinventor.components.annotations.SimpleFunction;
import com.google.appinventor.components.annotations.SimpleObject;
import com.google.appinventor.components.common.ComponentCategory;
import com.google.appinventor.components.runtime.*;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;

@DesignerComponent(version = 1,
    description = "Convert Hexadecimal to  Float - Big Endian (ABCD) - KIO4.COM ",
    category = ComponentCategory.EXTENSION,
    nonVisible = true,
    iconName = "") 
@SimpleObject(external = true)
public class KIO4_HexToDec extends AndroidNonvisibleComponent implements Component {
    private ComponentContainer container;
    public KIO4_HexToDec(ComponentContainer container) {

@SimpleFunction(description = "Convert hexadecimal to Float - Big Endian (ABCD).")
public String Convert(String hex) {
    byte[] bytes = new byte[4];
    for (int i = 0; i < 4; i++) {
        bytes[i] = (byte) Integer.parseInt(hex.substring(i * 2, i * 2 + 2), 16);
    ByteBuffer buffer = ByteBuffer.wrap(bytes).order(ByteOrder.BIG_ENDIAN);
    float floatValue = buffer.getFloat();
    return String.valueOf(floatValue);
}	// ==> FIN

1 Like

i get this error
in the next few days I try to update the tablet to lollipop 5, I had already done it but it was very slow and I went back.
thanks again for your effort

MIT AI2 Companion gives that error (connect/USB) but if I create the APK and install it on the table then it works and converts fine

I am ashamed to write to you
i tried the connection ("ai companion") and it works
I tried again with (USB) and now it works

1 Like