ant数据类型的范围意味着什么? [英] What range mean for ant data type?

查看:102
本文介绍了ant数据类型的范围意味着什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对数据类型的大小和范围感到困惑,我想举个例子:
以sbyte为单位,其大小为1个字节,范围为-128至127.
它是带符号的数据类型.它的大小是8位.
如果我声明变量

I am confused with the size ans range of datatypes.I want to quote example for this:
In sbyte ,its size is 1 byte and range is -128 to 127.
and it is signed datatype. its size is 8 bits.
If I declare variable

sbyte a;
                     a=-128;


其二进制格式为10000000
占用8位,但在有符号数据类型中保留1位用于有符号用途(即0表示正数,1表示负数),此处为1
因此二进制格式将为110000000

现在,它将无法满足sbyte
定义的范围和大小 因为它的大小是9位.
这是我的解释
请告诉我我是对的,如果有错,请纠正我.


Its binary form is 10000000
taking 8 bits but in signed datatype 1 bit is reserved for signed purpose (i.e 0 for positive number and 1 for negative number) here its 1
so binary form will be 110000000

Now, it wont satisfy the range and size which is defined by sbyte
as its size is 9 bits .
This is my interpretation
Please tell me am i right and if wrong,Please rectify me

推荐答案

http://en.wikipedia.org/wiki/Signed_number_representations [^ ]


这篇关于ant数据类型的范围意味着什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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