为什么不Math.Round /上限/下限返回长或诠释? [英] Why doesn't Math.Round/Floor/Ceiling return long or int?

查看:128
本文介绍了为什么不Math.Round /上限/下限返回长或诠释?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

的时候,我用 Math.Round /上限/下限我总是投以 INT (或者如果需要的话)。到底为什么这样做,他们返回,如果它总是返回一个整数。

Every time I use Math.Round/Floor/Ceiling I always cast to int (or perhaps long if necessary). Why exactly do they return double if it's always returning an integer.

推荐答案

结果可能不适合一个int(或长期)。的两倍的范围要大得多。

The result might not fit into an int (or a long). The range of a double is much greater.

大致范围双:±5.0×10 -324 到±1.7×10 308

Approximate range of double: ±5.0 × 10−324 to ±1.7 × 10308

(来源)

这篇关于为什么不Math.Round /上限/下限返回长或诠释?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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