如何表示系统中的最大数字 [英] How to represent the biggest number in a system

查看:88
本文介绍了如何表示系统中的最大数字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

让我们说没有检查包含文件,我们如何在系统中代表

最大的说法?


我遇到过本书给出了这段代码:


long int maximum = 0x7FFFFFFF;


这是否意味着该系统的long int只有32位?如果我们知道特定系统中的
,那么long int是64位,我们应该写:


long int maximum = 0x7FFFFFFFFFFFFFFF?


那么这本书写于1994年。


谢谢。

let''s say without checking including files, how do we to represent the
biggest say int in a system?

I ran across a book give this code:

long int biggest = 0x7FFFFFFF;

Does that mean the long int at that system is only 32 bits? If we know
in a particular system, the long int is 64 bits, shall we write:

long int biggest = 0x7FFFFFFFFFFFFFFF?

By the way, the book is written in 1994.

Thank you.

推荐答案

fd*******@gmail.com 写道:

让我们说没有检查包含文件,我们如何在系统中代表

最大说int?


我跑过一本书给出了这段代码:


long int maximum = 0x7FFFFFFF;


这是否意味着长那个系统的int只有32位?
let''s say without checking including files, how do we to represent the
biggest say int in a system?

I ran across a book give this code:

long int biggest = 0x7FFFFFFF;

Does that mean the long int at that system is only 32 bits?



不,当long int为64位(或任何其他允许的
位数)时,它也会起作用。当long int有超过32个(非填充)位时,

你将得到正好是0x7FFFFFFF,而不是最大值。还有更多

足够的情况,这正是预期的,你的

帖子并没有说明是否可以用于代码

这样的情况。

No, it will also work when long int is 64 bits (or any other allowable
number of bits). When long int has more than 32 (non-padding) bits,
you will get exactly 0x7FFFFFFF, not the maximum value. There are more
than enough situations when this is exactly what''s intended, and your
post doesn''t say enough to clarify whether the code might be used in
such a situation.


如果我们知道特定系统中的
,那么long int是64位,我们应该写:


long int maximum = 0x7FFFFFFFFFFFFFFF?
If we know
in a particular system, the long int is 64 bits, shall we write:

long int biggest = 0x7FFFFFFFFFFFFFFF?



如果你想要long int的最大值,包括< limits.h>,和

使用LONG_MAX。

If you want the maximum value for a long int, include <limits.h>, and
use LONG_MAX.


2月2日,2:35?* pm,Harald van D?3k < true ... @ gmail.comwrote:
On Feb 2, 2:35?*pm, "Harald van D?3k" <true...@gmail.comwrote:

fdmfdm ... @ gmail.com写道:
fdmfdm...@gmail.com wrote:

让我们说没有检查包含文件,我们如何在系统中代表

最大说int?
let''s say without checking including files, how do we to represent the
biggest say int in a system?


我跑过一本书给出这段代码:
I ran across a book give this code:


long int largest = 0x7FFFFFFF;
long int biggest = 0x7FFFFFFF;


这是否意味着该系统的long int只有32位?
Does that mean the long int at that system is only 32 bits?



不,当long int为64位(或任何其他允许的
位数)时,它也会起作用。当long int有超过32个(非填充)位时,

你将得到正好是0x7FFFFFFF,而不是最大值。还有更多

足够的情况,这正是预期的,你的

帖子并没有说明是否可以用于代码

这样的情况。


No, it will also work when long int is 64 bits (or any other allowable
number of bits). When long int has more than 32 (non-padding) bits,
you will get exactly 0x7FFFFFFF, not the maximum value. There are more
than enough situations when this is exactly what''s intended, and your
post doesn''t say enough to clarify whether the code might be used in
such a situation.


如果我们知道特定系统中的
,那么long int是64位,我们应该写:
If we know
in a particular system, the long int is 64 bits, shall we write:


long int largest = 0x7FFFFFFFFFFFFFFF?
long int biggest = 0x7FFFFFFFFFFFFFFF?



如果你想要long int的最大值,包括< limits.h>,和

使用LONG_MAX。


If you want the maximum value for a long int, include <limits.h>, and
use LONG_MAX.



根据我的理解,F代表1111,那么为什么0x7FFFFFFF将如何表示
代表超过32位的某些值?请原谅我的愚蠢



To my understanding, F represents 1111, so how come 0x7FFFFFFF will
represent some value more than 32 bits? Please forgive my stupidity
ahead.


fd ******* @ gmail.com 写道:

2月2日下午2:35,Harald van D?3k < true ... @ gmail.comwrote:
On Feb 2, 2:35 pm, "Harald van D?3k" <true...@gmail.comwrote:

>> fdmfdm ... @ gmail.com写道:
>>fdmfdm...@gmail.com wrote:

>>>让我们说不检查包含文件,我们如何在系统中代表最大的说法?
>>>let''s say without checking including files, how do we to represent the
biggest say int in a system?


>>>我跑过一本书给出了这段代码:
>>>I ran across a book give this code:


>>> long int largest = 0x7FFFFFFF;
>>>long int biggest = 0x7FFFFFFF;


>>>这是否意味着该系统的long int只有32位?
>>>Does that mean the long int at that system is only 32 bits?


不,当long int为64位(或任何其他允许的位数)时,它也可以工作。当long int有超过32个(非填充)位时,
将获得正好0x7FFFFFFF,而不是最大值。当这完全符合预期时,有足够多的情况,而你的
帖子并没有说明是否可以在这种情况下使用代码。


No, it will also work when long int is 64 bits (or any other allowable
number of bits). When long int has more than 32 (non-padding) bits,
you will get exactly 0x7FFFFFFF, not the maximum value. There are more
than enough situations when this is exactly what''s intended, and your
post doesn''t say enough to clarify whether the code might be used in
such a situation.


>>>如果我们知道特定系统中的
,那么long int是64位,我们应该写:
>>>If we know
in a particular system, the long int is 64 bits, shall we write:


>>> long int largest = 0x7FFFFFFFFFFFFFFF?
>>>long int biggest = 0x7FFFFFFFFFFFFFFF?


如果你想要long int的最大值,包括< limits.h>,并且
使用LONG_MAX。


If you want the maximum value for a long int, include <limits.h>, and
use LONG_MAX.




根据我的理解,F代表1111,那么为什么0x7FFFFFFF将来b / b
代表超过32位的值?请原谅我的愚蠢

提前。



To my understanding, F represents 1111, so how come 0x7FFFFFFF will
represent some value more than 32 bits? Please forgive my stupidity
ahead.



它没有,对于任何类型的> = 32
位。这可能是,也可能不是该类型的最大值。


-

Ian Collins。

It doesn''t, it represents exactly 0x7FFFFFFF for any type with >= 32
bits. This may, or may not, be the maximum value for the type.

--
Ian Collins.


这篇关于如何表示系统中的最大数字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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