Data update
This commit is contained in:
parent
5150844a7d
commit
4bb20c9b71
7735 changed files with 38060 additions and 199180 deletions
|
|
@ -1,51 +0,0 @@
|
|||
with Ada.Text_IO; use Ada.Text_IO;
|
||||
|
||||
procedure Overflow is
|
||||
|
||||
generic
|
||||
type T is Range <>;
|
||||
Name_Of_T: String;
|
||||
procedure Print_Bounds; -- first instantiate this with T, Name
|
||||
-- then call the instantiation
|
||||
procedure Print_Bounds is
|
||||
begin
|
||||
Put_Line(" " & Name_Of_T & " " & T'Image(T'First)
|
||||
& " .." & T'Image(T'Last));
|
||||
end Print_Bounds;
|
||||
|
||||
procedure P_Int is new Print_Bounds(Integer, "Integer ");
|
||||
procedure P_Nat is new Print_Bounds(Natural, "Natural ");
|
||||
procedure P_Pos is new Print_Bounds(Positive, "Positive");
|
||||
procedure P_Long is new Print_Bounds(Long_Integer, "Long ");
|
||||
|
||||
type Unsigned_Byte is range 0 .. 255;
|
||||
type Signed_Byte is range -128 .. 127;
|
||||
type Unsigned_Word is range 0 .. 2**32-1;
|
||||
type Thousand is range 0 .. 999;
|
||||
type Signed_Double is range - 2**63 .. 2**63-1;
|
||||
type Crazy is range -11 .. -3;
|
||||
|
||||
procedure P_UB is new Print_Bounds(Unsigned_Byte, "U 8 ");
|
||||
procedure P_SB is new Print_Bounds(Signed_Byte, "S 8 ");
|
||||
procedure P_UW is new Print_Bounds(Unsigned_Word, "U 32 ");
|
||||
procedure P_Th is new Print_Bounds(Thousand, "Thous");
|
||||
procedure P_SD is new Print_Bounds(Signed_Double, "S 64 ");
|
||||
procedure P_Cr is new Print_Bounds(Crazy, "Crazy");
|
||||
|
||||
A: Crazy := Crazy'First;
|
||||
|
||||
begin
|
||||
Put_Line("Predefined Types:");
|
||||
P_Int; P_Nat; P_Pos; P_Long;
|
||||
New_Line;
|
||||
|
||||
Put_Line("Types defined by the user:");
|
||||
P_UB; P_SB; P_UW; P_Th; P_SD; P_Cr;
|
||||
New_Line;
|
||||
|
||||
Put_Line("Forcing a variable of type Crazy to overflow:");
|
||||
loop -- endless loop
|
||||
Put(" " & Crazy'Image(A) & "+1");
|
||||
A := A + 1; -- line 49 -- this will later raise a CONSTRAINT_ERROR
|
||||
end loop;
|
||||
end Overflow;
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
IDENTIFICATION DIVISION.
|
||||
PROGRAM-ID. PROCRUSTES-PROGRAM.
|
||||
DATA DIVISION.
|
||||
WORKING-STORAGE SECTION.
|
||||
01 WS-EXAMPLE.
|
||||
05 X PIC 999.
|
||||
PROCEDURE DIVISION.
|
||||
MOVE 1002 TO X.
|
||||
DISPLAY X UPON CONSOLE.
|
||||
STOP RUN.
|
||||
|
|
@ -1,78 +0,0 @@
|
|||
identification division.
|
||||
program-id. overflowing.
|
||||
|
||||
data division.
|
||||
working-storage section.
|
||||
01 bit8-sized usage binary-char. *> standard
|
||||
01 bit16-sized usage binary-short. *> standard
|
||||
01 bit32-sized usage binary-long. *> standard
|
||||
01 bit64-sized usage binary-double. *> standard
|
||||
01 bit8-unsigned usage binary-char unsigned. *> standard
|
||||
|
||||
01 nebulous-size usage binary-c-long. *> extension
|
||||
|
||||
01 picture-size picture s999. *> standard
|
||||
|
||||
*> ***************************************************************
|
||||
procedure division.
|
||||
|
||||
*> 32 bit signed integer
|
||||
subtract 2147483647 from zero giving bit32-sized
|
||||
display bit32-sized
|
||||
|
||||
subtract 1 from bit32-sized giving bit32-sized
|
||||
ON SIZE ERROR display "32bit signed SIZE ERROR"
|
||||
end-subtract
|
||||
*> value was unchanged due to size error trap and trigger
|
||||
display bit32-sized
|
||||
display space
|
||||
|
||||
*> 8 bit unsigned, size tested, invalid results discarded
|
||||
add -257 to zero giving bit8-unsigned
|
||||
ON SIZE ERROR display "bit8-unsigned SIZE ERROR"
|
||||
end-add
|
||||
display bit8-unsigned
|
||||
|
||||
*> programmers can ignore the safety features
|
||||
compute bit8-unsigned = -257
|
||||
display "you asked for it: " bit8-unsigned
|
||||
display space
|
||||
|
||||
*> fixed size
|
||||
move 999 to picture-size
|
||||
add 1 to picture-size
|
||||
ON SIZE ERROR display "picture-sized SIZE ERROR"
|
||||
end-add
|
||||
display picture-size
|
||||
|
||||
*> programmers doing the following, inadvertently,
|
||||
*> do not stay employed at banks for long
|
||||
move 999 to picture-size
|
||||
add 1 to picture-size
|
||||
*> intermediate goes to 1000, left end truncated on storage
|
||||
display "you asked for it: " picture-size
|
||||
|
||||
add 1 to picture-size
|
||||
display "really? you want to keep doing this?: " picture-size
|
||||
display space
|
||||
|
||||
*> C values are undefined by spec, only minimums givens
|
||||
display "How many bytes in a C long? "
|
||||
length of nebulous-size
|
||||
", varies by platform"
|
||||
display "Regardless, ON SIZE ERROR will catch any invalid result"
|
||||
|
||||
*> on a 64bit machine, C long of 8 bytes
|
||||
add 1 to h'ffffffffffffffff' giving nebulous-size
|
||||
ON SIZE ERROR display "binary-c-long SIZE ERROR"
|
||||
end-add
|
||||
display nebulous-size
|
||||
*> value will still be in initial state, GnuCOBOL initializes to 0
|
||||
*> value now goes to 1, no size error, that ship has sailed
|
||||
add 1 to nebulous-size
|
||||
ON SIZE ERROR display "binary-c-long size error"
|
||||
end-add
|
||||
display "error state is not persistent: ", nebulous-size
|
||||
|
||||
goback.
|
||||
end program overflowing.
|
||||
|
|
@ -1,30 +0,0 @@
|
|||
try {
|
||||
# All of these raise an exception, which is caught below.
|
||||
# The try block is aborted after the first exception,
|
||||
# so the subsequent lines are never executed.
|
||||
|
||||
[int32] (-(-2147483647-1))
|
||||
[int32] (2000000000 + 2000000000)
|
||||
[int32] (-2147483647 - 2147483647)
|
||||
[int32] (46341 * 46341)
|
||||
[int32] ((-2147483647-1) / -1)
|
||||
|
||||
[int64] (-(-9223372036854775807-1))
|
||||
[int64] (5000000000000000000+5000000000000000000)
|
||||
[int64] (-9223372036854775807 - 9223372036854775807)
|
||||
[int64] (3037000500 * 3037000500)
|
||||
[int64] ((-9223372036854775807-1) / -1)
|
||||
|
||||
[uint32] (-4294967295)
|
||||
[uint32] (3000000000 + 3000000000)
|
||||
[uint32] (2147483647 - 4294967295)
|
||||
[uint32] (65537 * 65537)
|
||||
|
||||
[uint64] (-18446744073709551615)
|
||||
[uint64] (10000000000000000000 + 10000000000000000000)
|
||||
[uint64] (9223372036854775807 - 18446744073709551615)
|
||||
[uint64] (4294967296 * 4294967296)
|
||||
}
|
||||
catch {
|
||||
$Error.Exception
|
||||
}
|
||||
|
|
@ -1,14 +0,0 @@
|
|||
'Binary Integer overflow - vbs
|
||||
i=(-2147483647-1)/-1
|
||||
wscript.echo i
|
||||
i0=32767 '=32767 Integer (Fixed) type=2
|
||||
i1=2147483647 '=2147483647 Long (Fixed) type=3
|
||||
i2=-(-2147483647-1) '=2147483648 Double (Float) type=5
|
||||
wscript.echo Cstr(i0) & " : " & typename(i0) & " , " & vartype(i0) & vbcrlf _
|
||||
& Cstr(i1) & " : " & typename(i1) & " , " & vartype(i1) & vbcrlf _
|
||||
& Cstr(i2) & " : " & typename(i2) & " , " & vartype(i2)
|
||||
ii=2147483648-2147483647
|
||||
if vartype(ii)<>3 or vartype(ii)<>2 then wscript.echo "Integer overflow type=" & typename(ii)
|
||||
i1=1000000000000000-1 '1E+15-1
|
||||
i2=i1+1 '1E+15
|
||||
wscript.echo Cstr(i1) & " , " & Cstr(i2)
|
||||
Loading…
Add table
Add a link
Reference in a new issue