可以双打用于重新present一个64位的数不precision的损失 [英] Can doubles be used to represent a 64 bit number without loss of precision

查看:221
本文介绍了可以双打用于重新present一个64位的数不precision的损失的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用LUA(即在内部使用只双打)重新present不能有0和2 ^ 64-1或可怕的事情之间的舍入误差会发生一个整数。

I want to use lua (that internally uses only doubles) to represent a integer that can't have rounding errors between 0 and 2^64-1 or terrible things will happen.

是否可以这样做呢?

推荐答案

目前至少一个64位双的某些位必须被用于重新present指数(二进制点位置),因此有大于64位的较少可用的实际数量。所以,不,一个64位双不能重新present所有值的64位整数能(反之亦然)。

At least some bits of a 64-bit double must be used to represent the exponent (position of the binary point), and hence there are fewer than 64-bits available for the actual number. So no, a 64-bit double can't represent all the values a 64-bit integer can (and vice-versa).

这篇关于可以双打用于重新present一个64位的数不precision的损失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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