型の表現範囲を表示

明解C言語 入門編 > 7. 基本型 >

型の表現範囲を表示

Delphi


program Project1;

{$APPTYPE CONSOLE}

uses
SysUtils, Math;

procedure main();
var
a: Shortint;
b: Smallint;
c: Longint;
d: Byte;
e: Word;
f: Integer;
g: Cardinal;
o: Single;
p: Double;
q: Extended;
r: Real;
v: Comp;
x: Currency;
y: Extended;
begin
writeln(format('ShortInt : %d〜%d', [low(a), high(a)]));
writeln(format('SmallInt : %d〜%d', [low(b), high(b)]));
writeln(format('LongInt : %d〜%d', [low(c), high(c)]));
writeln(format('Byte : %d〜%d', [low(d), high(d)]));
writeln(format('Word : %d〜%d', [low(e), high(e)]));
writeln(format('Integer : %d〜%d', [low(f), high(f)]));
writeln(format('Cardinal : %u〜%u', [low(g), high(g)]));

writeln(format('Single : %g〜%g', [MinSingle, MaxSingle]));
writeln(format('Double : %g〜%g', [MinDouble, MaxDouble]));
writeln(format('Extended : %g〜%g', [MinExtended, MaxExtended]));
writeln(format('Comp : %g〜%g', [MinComp, MaxComp]));

// writeln(format('Currency :
end;

begin
main;
end.

実行結果

S:\>lesson059\project1.exe
ShortInt : -128〜127
SmallInt : -32768〜32767
LongInt : -2147483648〜2147483647
Byte : 0〜255
Word : 0〜65535
Integer : -2147483648〜2147483647
Cardinal : 0〜4294967295
Single : 1.5E-45〜3.4E38
Double : 5E-324〜1.7E308
Extended : 3.4E-4932〜1.1E4932
Comp : -9.22337203685478E18〜9.22337203685478E18