program fjf170;
Type
  RealType    = ShortReal;
  IntegerType = Integer ( BitSizeOf ( RealType ) );

Var
  r, r1, r2, r3, r4:     RealType;
  i, i1, i2, i3, i4, i5: IntegerType;

(* On some machines, these casts cause floating point exceptions. *)

begin
  i := 42;
  IntegerType (r1) := i;
  r2 := RealType (i+0);
  r3 := RealType (i);
  r4 := i;
  r := 41.9;
  RealType (i1) := r;
  i3 := IntegerType (r);
  i4 := Round (r); { 42 }
  i5 := Trunc (r); { 41 }
  if (r1<>42) and (r2=42) and (r3=42) and (r4=42) and
     (i1<>41) and (i1<>42) and (i3<>41) and (i3<>42) and (i4=42) and (i5=41)
    then writeln('OK')
  else
    begin
      writeln ( 'failed: ' );
      if r1 = 42 then
        writeln ( 'r1 = ', r1 );
      if r2 <> 42 then
        writeln ( 'r2 = ', r2 );
      if r3 <> 42 then
        writeln ( 'r3 = ', r3 );
      if r4 <> 42 then
        writeln ( 'r4 = ', r4 );
      if i1 in [ 41, 42 ] then
        writeln ( 'i1 = ', i1 );
      if i3 in [ 41, 42 ] then
        writeln ( 'i3 = ', i3 );
      if i4 <> 42 then
        writeln ( 'i4 = ', i4 );
      if i5 <> 41 then
        writeln ( 'i5 = ', i5 )
    end (* else *)
end.
