package Rational_Numbers is type Rational_Type is tagged private; function To_Ratio (Numerator, Denominator : Integer) return Rational_Type; -- возбуждает Constraint_Error когда Denominator = 0 function Numerator (Rational : Rational_Type) return Integer; function Denominator (Rational : Rational_Type) return Positive; -- результат не нормализован к множителю общих делителей ... -- другие операции: "+", "-", "*", "/", ... private ... end Rational_Numbers; |
with Rational_Numbers, Text_IO; generic type Num_Type is new Rational_Numbers.Rational_Type with private; package Rational_IO is procedure Get (File : in Text_IO.File_Type; Item : out Num_Type); procedure Put (File : in Text_IO.File_Type; Item : in Num_Type); end Rational_IO; |