# How to set Precision with a variable? [closed]

I get confusing output from the code below. If I put a number after a variable value, the precision gets set just fine. But if I put a variable after the backtick, MMa multiplies the values.

Three part question: Can anyone make sense of the confusing outputs? Why does N[] give delta the correct precision but not center? How can I create a value for center with precision equal to prec?

center = -1.4011551890920506007550
center // Precision
center = N[-1.40115518909205060075, 50]
center // Precision


(* -1.4011551890920506007500000000000000000000000000000

50.

-1.4011551890920506008

20.1465 *)

prec = 50
delta = N[(3*10^-19), prec]
center = N[-1.40115518909205060075, prec]
delta // Precision
center // Precision


(* 50

3.0000000000000000000000000000000000000000000000000*10^-19

-1.4011551890920506008

50.

20.1465 *)

center = -1.40115518909205060075 prec
center // Precision


(*

-70.0578

MachinePrecision

*)

## closed as off-topic by MarcoB, user9660, Michael E2, bbgodfrey, dr.blochwaveMar 7 '16 at 13:25

This question appears to be off-topic. The users who voted to close gave this specific reason:

• "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – MarcoB, Community, Michael E2, bbgodfrey, dr.blochwave
If this question can be reworded to fit the rules in the help center, please edit the question.

• Remember that N does not increase the precision of a number. – bbgodfrey Mar 5 '16 at 2:17
• @bbgodfrey It increases the precision of delta in my code. – Jerry Guern Mar 5 '16 at 2:18
• Why not use SetPrecision[] instead? – J. M. will be back soon Mar 5 '16 at 2:18
• 3*10^-19 is an exact (infinite precision) number, and N in this case reduces it to a precision of 50. – bbgodfrey Mar 5 '16 at 2:23

center = -1.40115518909205060075prec won't work. You simply can't use variables in such expressions because the input processor is not programmed to pass expressions like 1.23n to an evaluator. It interprets them as 1.23*n and passes that to the evaluator.
• The situation is similar to that of numbers in alternate bases and numbers in abbreviated exponential notation: 2^^1001 and 2*^5 work, but x^^1001 and 2*^x don't. – J. M. will be back soon Mar 5 '16 at 11:37