NodeMCU Lua整数最大值是2 ^ 31 [英] NodeMCU Lua integer max value is 2^31

查看:213
本文介绍了NodeMCU Lua整数最大值是2 ^ 31的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

SDK 3.0.1-dev(fce080e)
上的Lua 5.1.4尝试使用node.dsleepMax()并返回一个非常小的数字(147324921)。然后,我尝试将node.dsleep中的睡眠时间手动设置为32位最大值(4294967295),并且它仅保持睡眠状态约30分钟左右。

Lua 5.1.4 on SDK 3.0.1-dev(fce080e) Trying to use node.dsleepMax() and it is returning a really smaller number (147324921). Then I tried to manually set the sleep time in node.dsleep to the 32-bit max value (4294967295) and it only remained sleeping for around 30 min or so.

尝试以下操作:

    sleeptime = 4294967295
    > 
    =print(sleeptime)

2147483647

即2 ^ 31 -1

which is 2^31 -1.

还对变量添加了一个循环,当它达到2 ^ 31时它就变成负变量。

Also did a loop adding to a variable, and it becomes negatve when it reaches 2^31.

问题:


  1. 为什么变量在2 ^ 31处换行?

  2. node.dsleep不是应该通过SDK接受64位值吗? 2.1及更高版本?

问候,

Cesar

推荐答案

您已经获得了有关int与float的反馈。至于 dsleep 文档没有明确声明它接受64位值,但这确实是根据 https://github.com/nodemcu/nodemcu-firmware/pull/2358 (自2018年4月开始)。

You already got some feedback regarding int vs. float. As for dsleep the documentation doesn't explicitly state that it accepts 64bit values but that's indeed what's happening as per https://github.com/nodemcu/nodemcu-firmware/pull/2358 (since April 2018).

这篇关于NodeMCU Lua整数最大值是2 ^ 31的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆