mathluacan-bus

How do I use ldexp in lua 5.4 as math.ldexp(...) is deprecated


I am trying to write a uint32_to_float function in lua where I am using math.ldexp in a condition. Upon checking the script using luacheck, I get following error:

 scripts/CAN test.lua:58:21: accessing undefined field ldexp of global math

How do I fix the problem and could anyone suggest me with an alternative?


Solution

  • Quote from the official manual

    you can replace math.ldexp(x,exp) with x * 2.0^exp