• Announcement: Lua.org now officially recommends this forum as a meeting place for the Lua community

Lua ignoring float type (1 Viewer)

Ane

Newcomer
Joined
Sep 22, 2021
Messages
1
Reaction score
0
Hello,
I´m calling a function in lua to get some data via ubus. I need to show this info in a web. The table this method returns is the following. The problem is lua is just getting some of the data, not all. I can´t get the float values. When I iterate the table c_r, c_s, c_t and soc don´t exists.
Code:
    "socket1": {
        "state": "charging",
        "energy": 2544,
        "power": 1766,
        "soc": 0.000000,
        "c_r": 8.079000,
        "c_s": 0.000000,
        "c_t": 0.000000,
        "energy_limit": 0
    },
I don't know how to fix this. I've tried to change the value format of c_s, c_r and c_t to integer and it works fine, but I need them to be floats.

Thanks in advance,
 
Last edited by a moderator:

225559

Newcomer
Joined
Nov 17, 2020
Messages
20
Reaction score
7
What device are you using? Does it support floating point numbers?
 

Herly Quijano

Newcomer
Joined
Mar 19, 2021
Messages
70
Reaction score
7
The library math have a function called math.type(number) that returns "float" or "integer" depending on the number or nil if is not a number, you can use it to see what is happening.
 
Top