十個月前有一串 "整數怎麼不會溢位了 ?" 記得曾經討論過 ...
就不扯遠或 "推論" 了,來看看規格是怎麼說的:
※ 引述《tinlans.bbs@whshs.cs.nccu.edu.tw (汀)》之銘言:
> ISO/IEC 9899:1999 的 p.22 的小節名稱是:
> 5.2.4.2.1 Sizes of integer types <limits.h>
> 裡面記載了整數數值的值域定義,
> 在 p.21 最後面寫了一句話:
> Their implementation-defined values shall be equal or greater in
> magnitude (absolute value) to those shown, with the same sign.
> 而 p.22 對 INT_MIN 和 INT_MAX 的說明為:
> - minimum value for an object of type int
> INT_MIN -32767 // -(2**15 - 1)
> - maximum value for an object of type int
> INT_MAX +32767 // 2**15 - 1
> 所以從這點看來應該可以解讀成是必須至少有 16-bit 沒錯。
然後再補充一下, p.33 Sec. 6.2.5 Types, paragraph 5:
An object declared as type signed char occupies the same amount of storage
as a "plain" char object. A "plain" int object has the natural size
suggested by the architecture of the execution environment (large enough
to contain any value in the range INT_MIN to INT_MAX as defined
in the header <limits.h>).
--
╔╮ ▅▇▆▇█▆▅▇▅▄▇▆▅▆▄ ○ ‧ . 。 ο ˙ ﹒.ο . ˙﹒ ○β
╰╝╭╗▊ 天空之城 (qazq.twbbs.org) ▊ο 。 ξ期待在空中與你相會 。 δ▼
╚╯ ▄▃▄▅▄▂▅▆▄▂▆▄▂▅▆ 59-126-44-151.HINET-IP.hinet.net 〝