SAY討論區

標題: Delphi- SmallInt,為什么會這樣的?? [打印本頁]

作者: frankyhui    時間: 2012-5-12 02:19:13     標題: Delphi- SmallInt,為什么會這樣的??

SmallInt 的范围是 “-32768 to 32767”
下图所指 32767 + 1 那麼应该是 32768。为什麼它会显示 -32768??


图2 “32767 + 7” 应该是 32774。为什麼是 “-32762”??


图3 又怎麼算??


图4 把它换成 -32768 + 111。 为什麼会正確的算出??


以下是代码:<div class="blockcode"><span class="headactions" onclick="copycode($('code0'));">複製內容到剪貼板</span><h5>代碼:</h5><code id="code0">implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
X : SmallInt;
begin
X := -32768;
X := X + 111;
Label1.Caption := IntToStr(X);
end;

end.</code>
作者: freegold    時間: 2012-5-13 23:37:54

鑒定完畢.!
作者: ILOVEU5    時間: 2012-5-13 23:37:54

要多久才能升級啊
作者: HOTSTUDIO阿蚊    時間: 2012-5-13 23:37:54

哈哈 瞧你說的~~~  




歡迎光臨 SAY討論區 (http://say.go2tutor.com/) Powered by Discuz! X2