Using precision in Mathematica code [duplicate]

I would like to use a specific precision for several different calculations in Mathematica code. I know that using SetPrecision can give you the required precision for specific calculation. What I would like to know is if there is a way to set the precision at the beginning of the code for all calculations that you have in your code rather than repeating writing the precision command for each individual calculation. In the following example,

prc=20; (* required precision *)
x=5;
y=10;
y1=SetPrecision[x^2 Sin[90],prc]
y2=SetPrecision[Cos[90+y],prc]
y3=SetPrecision[Tan[90-x],prc]


I would like to define or set the precision at the beginning of the code rather than repeating SetPrecision command for each individual calculation y1, y2, and y3 . How this can be done?

• Setting $MinPrecision might do what you want, but in the Possible Issues section it states that it doesn't override machine precision. – Patrick Stevens Aug 21 '15 at 11:38 • Block[{$MinPrecision = prec, \$MaxPrecision = prec}, code]. But, as @PatrickStevens says, you must ensure all numbers are arbitrary (rather than machine) precision quantities in order for this to work. – Oleksandr R. Aug 21 '15 at 11:42
• – Szabolcs Aug 21 '15 at 12:16