int和float的大小 [英] Size of int and float

查看:237
本文介绍了int和float的大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个关于整数的范围问题,花车:

I have a question about the ranges of ints and floats:

如果它们都具有4个字节大小相同,为什么他们有不同的范围?

If they both have the same size of 4 bytes, why do they have different ranges?

推荐答案

它们是完全不同的 - 通常 INT 只是一个简单的2的补符号整数,而浮动是一个单precision浮点重新presentation与尾数23位,8位指数和1位符号(见<一href=\"http://en.wikipedia.org/wiki/IEEE_754-2008\">http://en.wikipedia.org/wiki/IEEE_754-2008).

They are totally different - typically int is just a straightforward 2's complement signed integer, while float is a single precision floating point representation with 23 bits of mantissa, 8 bits exponent and 1 bit sign (see http://en.wikipedia.org/wiki/IEEE_754-2008).

这篇关于int和float的大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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