DataMuseum.dk

Presents historical artifacts from the history of:

Rational R1000/400

This is an automatic "excavation" of a thematic subset of
artifacts from Datamuseum.dk's BitArchive.

See our Wiki for more about Rational R1000/400

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - download

⟦c5cdc1bc4⟧ Ada Source

    Length: 5120 (0x1400)
    Types: Ada Source
    Notes: 03_class, FILE, R1k_Segment, e3_tag, package body Numeric_Primitives, seg_00ea09

Derivation

└─⟦8527c1e9b⟧ Bits:30000544 8mm tape, Rational 1000, Arrival backup of disks in PAM's R1000
    └─ ⟦cfc2e13cd⟧ »Space Info Vol 2« 
        └─⟦this⟧ 

E3 Source Code



with Floating_Characteristics;
use Floating_Characteristics;

package body Numeric_Primitives is

    function Sign (X, Y : Float) return Float is
        --  Returns the value of X with the sign of Y
    begin
        if Y >= 0.0 then
            return X;
        else
            return -X;
        end if;
    end Sign;

    function Max (X, Y : Float) return Float is
    begin
        if X >= Y then
            return X;
        else
            return Y;
        end if;
    end Max;

    function Min (X, Y : Float) return Float is
    begin
        if X <= Y then
            return X;
        else
            return Y;
        end if;
    end Min;

    function Truncate (X : Float) return Float is
        --  Optimum code depends on how the system rounds at exact halves
    begin
        if Float (Integer (X)) = X then
            return X;
        end if;

        if X > Zero then
            return Float (Integer (X - Half));
        elsif X = Zero then
            return Zero;
        else
            return Float (Integer (X + Half));
        end if;
    end Truncate;

    function Round (X : Float) return Float is
    begin
        return Float (Integer (X));
    end Round;

    package Key is
        X : Integer := 10_001;
        Y : Integer := 20_001;
        Z : Integer := 30_001;
    end Key;

    function Ran return Float is
        --  This rectangular random number routine is adapted from a report
        --  "A Pseudo-Random Number Generator" by B. A. Wichmann and I. D. Hill
        --  NPL Report DNACS XX (to be published)
        --  In this stripped version, it is suitable for machines supporting
        --  INTEGER at only 16 bits and is portable in Ada
        W : Float;
    begin
        Key.X := 171 * (Key.X mod 177 - 177) - 2 * (Key.X / 177);

        if Key.X < 0 then
            Key.X := Key.X + 30269;
        end if;

        Key.Y := 172 * (Key.Y mod 176 - 176) - 35 * (Key.Y / 176);

        if Key.Y < 0 then
            Key.Y := Key.Y + 30307;
        end if;

        Key.Z := 170 * (Key.Z mod 178 - 178) - 63 * (Key.Z / 178);

        if Key.Z < 0 then
            Key.Z := Key.Z + 30323;
        end if;

        --  CONVERT_TO_FLOAT is used instead of FLOAT since the floating
        --  type may be software defined
        W := Convert_To_Float (Key.X) / 30269.0 +
                Convert_To_Float (Key.Y) / 30307.0 +
                Convert_To_Float (Key.Z) / 30323.0;
        return W - Convert_To_Float (Integer (W - 0.5));
    end Ran;
begin
    Pi := Convert_To_Float (Integer (3)) +
             Convert_To_Float (Mantissa_Type (0.14159_26535_89793_23846));
    One_Over_Pi := Convert_To_Float (Mantissa_Type (0.31830_98861_83790_67154));
    Two_Over_Pi := Convert_To_Float (Mantissa_Type (0.63661_97723_67581_34308));
    Pi_Over_Two := Convert_To_Float (Integer (1)) +
                      Convert_To_Float
                         (Mantissa_Type (


                                         0.57079_63267_94896_61923));
    Pi_Over_Three := Convert_To_Float (Integer (1)) +
                        Convert_To_Float (Mantissa_Type
                                             (0.04719_75511_96597_74615));
    Pi_Over_Four := Convert_To_Float
                       (Mantissa_Type (0.78539_81633_97448_30962));
    Pi_Over_Six := Convert_To_Float (Mantissa_Type (0.52359_87755_98298_87308));
end Numeric_Primitives;


E3 Meta Data

    nblk1=4
    nid=0
    hdr6=8
        [0x00] rec0=2b rec1=00 rec2=01 rec3=042
        [0x01] rec0=21 rec1=00 rec2=02 rec3=008
        [0x02] rec0=18 rec1=00 rec2=03 rec3=066
        [0x03] rec0=0f rec1=00 rec2=04 rec3=001
    tail 0x2170b4f4082253d836e11 0x42a00088462063203