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

	Copyright 1989 by Roman E. Maeder
	
	Adapted from
	Roman E. Maeder: Programming in Mathematica, Addison-Wesley, 1989.

	Permission is hereby granted to make copies of this file for
	any purpose other than direct profit, or as part of a
	commercial product, provided this copyright notice is left
	intact.  Sale, other than for the cost of media, is prohibited.
	
	Permission is hereby granted to reproduce part or all of
	this file, provided that the source is acknowledged.

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


BeginPackage["RMPackages`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[Release[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;
	const/: const ^ r_ := N[const, Precision[r]] ^ r /; Precision[r] < Infinity
	)

DefineRules /@ constantList

Protect[Release[protected]]

End[]

EndPackage[]
