- Mastering Delphi Programming:A Complete Reference Guide
- Primo? Gabrijel?i?
- 180字
- 2021-06-24 12:33:34
Overflow checking
The Overflow checking option regulates whether the compiler checks if certain arithmetic operations (+, -, *, Abs, Sqr, Inc, Dec, Succ, and Pred) produce a number that is too large or too small to fit into the data type. You can use compiler options, {$OVERFLOWCHECKS ON} and {$OVERFLOWCHECKS OFF} (or short forms {$Q+} and {$Q-}), to turn this option on and off in a specific part of a program.
For example, the following program will silently increment $FFFFFFFF to 0 in the first Inc statement but will raise EIntOverflow exception in the second Inc statement:
procedure TfrmCompilerOptions.btnOverflowErrorClick(Sender: TObject);
var
i: cardinal;
begin
{$Q-}
i := $FFFFFFFF;
// Without overflow checks, Inc will work and i will be 0
Inc(i);
{$Q+}
i := $FFFFFFFF;
// With overflow checks, Inc will raise an exception
Inc(i);
end;
Enabling overflow checking doesn't make a big change in the program speed, so you can freely use it whenever it is needed. I would suggest turning it on at least in debug configuration as that will help with finding errors in the code.
- 零點(diǎn)起飛學(xué)Xilinx FPG
- 深入理解Spring Cloud與實(shí)戰(zhàn)
- 新型電腦主板關(guān)鍵電路維修圖冊(cè)
- Python GUI Programming:A Complete Reference Guide
- Effective STL中文版:50條有效使用STL的經(jīng)驗(yàn)(雙色)
- 嵌入式技術(shù)基礎(chǔ)與實(shí)踐(第5版)
- Intel FPGA/CPLD設(shè)計(jì)(高級(jí)篇)
- The Applied AI and Natural Language Processing Workshop
- 單片機(jī)原理及應(yīng)用系統(tǒng)設(shè)計(jì)
- OUYA Game Development by Example
- 計(jì)算機(jī)組裝維修與外設(shè)配置(高等職業(yè)院校教改示范教材·計(jì)算機(jī)系列)
- LPC1100系列處理器原理及應(yīng)用
- “硬”核:硬件產(chǎn)品成功密碼
- 圖解計(jì)算機(jī)組裝與維護(hù)
- Blender Game Engine:Beginner's Guide