with Natural_Package;  -- needs the Natural_Package.Log function
package body Base_Ten is
    --======================================================
    --=                                                    =
    --= This package provides a function to return the log =
    --= (to the base 10) of a number.  The number must be a=
    --= floating point number.  This package currently does=
    --= minimal error anlysis and numerical analysis to    =
    --= keep the correct accuracy and could, therefore use =
    --= some improvement.                                  =
    --=                                                    =
    --=                                                    =
    --= written by Brad Balfour with help from Ed Berard   =
    --= version 1.0                                        =
    --= June 16, 1985                                      =
    --=                                                    =
    --======================================================

    package New_Natural is new Natural_Package (Argument => Argument,
                                                Return_Value => Return_Value);

    function Log (Of_Value : in Argument) return Return_Value is

        -- written by Brad Balfour with help from Ed Berard
        -- version 1.0
        -- June 16, 1985
        -- computes the log to the base 10 of the number Of_Value.

        Natural_Log_Of_Ten : constant Return_Value := New_Natural.Log (10.0);

    begin
        -- Log

        if Of_Value <= 0.0 then
            raise Negative_Log;
        else
            -- ok to compute with argument > 0
            return Return_Value (New_Natural.Log (Of_Value => Of_Value) /
                                 Natural_Log_Of_Ten);
        end if;

    exception
        when New_Natural.Value_Too_Large =>
            raise Value_Too_Large;
    end Log;

end Base_Ten;