modf的使用

来源:互联网 发布:抱枕材料 知乎 编辑:程序博客网 时间:2024/05/17 23:50

分解x,以得到x的整数和小数部分

t 为多少秒

 math.modf(t / (60 * 60 * 24))

 math.modf(t % (60 * 60 * 24) / (60 * 60))

 math.modf(t % (60 * 60) / 60)

 math.modf(t % (60 * 60) % 60)

     local strLeftTime = string.format("%02d:%02d:%02d", math.modf(t % (60 * 60 * 24) / (60 * 60)), math.modf(t % (60 * 60) / 60), t % (60 * 60) % 60)

     local d = math.modf(t / (60 * 60 * 24))