- 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.
- 零點起飛學Xilinx FPG
- ATmega16單片機項目驅動教程
- Learning AngularJS Animations
- Linux運維之道(第2版)
- Manage Partitions with GParted How-to
- 計算機組裝與維修技術
- 微軟互聯網信息服務(IIS)最佳實踐 (微軟技術開發者叢書)
- Building 3D Models with modo 701
- 面向對象分析與設計(第3版)(修訂版)
- VMware Workstation:No Experience Necessary
- Hands-On Artificial Intelligence for Banking
- 基于PROTEUS的電路設計、仿真與制板
- Blender 3D By Example
- UML精粹:標準對象建模語言簡明指南(第3版)
- 計算機組裝、維護與維修項目教程