
(*********************************************************************

        Adapted from
        Roman E. Maeder: Programming in Mathematica,
        Second Edition, Addison-Wesley, 1991.

 *********************************************************************)


BeginPackage["NumericalMath`Constants`"]

Constants::usage = "Constants.m defines rules for approximate arithmetic with the
	mathematical constants Pi, Degree, GoldenRatio, E, EulerGamma and Catalan."

Begin["`Private`"]

constantList = {Pi, Degree, GoldenRatio, E, EulerGamma, Catalan}

protected = Unprotect[Evaluate[constantList]]

DefineRules[const_Symbol] := (
	const/: const + r_ := N[const, Accuracy[r]] + r /; Accuracy[r] < Infinity;
	const/: const * r_ := N[const, Precision[r]] * r /; Precision[r] < Infinity
	)

DefineRules /@ constantList

Protect[Evaluate[protected]]

End[]

EndPackage[]
