Ask Your Question
1

Precision in bits

asked 2022-01-10 19:58:19 +0100

user257 gravatar image

how do you convert precision in bits to number of decimal digits ? I couldn't find out the formula. googling didn't help either. What I'm asking is;

print(N(pi, prec=2)) gives 3.0

print(N(pi, prec=4)) gives 3.2

print(N(pi, prec=6)) gives 3.1

print(N(pi, prec=12)) gives 3.14

etc.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2022-01-10 21:44:06 +0100

tmonteil gravatar image

You can look at the documentation of N with:

sage: N?

You can see that, besides the prec option, there is a digit option that does the job:

sage: print(N(pi, digits=4))
3.142
sage: print(N(pi, digits=6))
3.14159
sage: print(N(pi, digits=12))
3.14159265359
edit flag offensive delete link more

Comments

Thanks, I know "digits", but I was interested whether there's a formula between these 2.

user257 gravatar imageuser257 ( 2022-01-11 18:19:36 +0100 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2022-01-10 19:58:19 +0100

Seen: 160 times

Last updated: Jan 10 '22