File: testdiv0.pas

package info (click to toggle)
ironseed 0.4.0-7
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 10,816 kB
  • sloc: pascal: 27,286; ansic: 795; makefile: 282; perl: 277; sh: 229
file content (27 lines) | stat: -rw-r--r-- 779 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
{
see https://github.com/mnalis/ironseed_fpc/issues/26
compile with:
fpc -Mtp -g -C3 -Ci -Co -CO  -O- -gl -gw -godwarfsets  -gt -gv -vw  -Sa testdiv0.pas
}

program testdiv0;

// runtime error 200 if not using SysUtils, EDivByZero if we use SysUtils
uses sysutils, math;

var a, b, c: integer;
var r, s, t: real;

begin
//    SetExceptionMask([exInvalidOp, exDenormalized, exZeroDivide, exOverflow, exUnderflow, exPrecision]);	// https://delphi.fandom.com/wiki/SetExceptionMask_Routine
    SetExceptionMask([exInvalidOp, exDenormalized, exPrecision]);    		// this helps against floating point division by zero (but not integer one)
    a:=0;
    b:=0;
    r:=0;
    s:=0;
    writeln('start');
    t:=r/s;
    writeln('real t=',t);
    c:=a div b;
    writeln('int c=',c);
end.