First time here? Check out the FAQ!

Ask Your Question
1

Precision in bits

asked 3 years ago

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.

Preview: (hide)

1 Answer

Sort by » oldest newest most voted
1

answered 3 years ago

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
Preview: (hide)
link

Comments

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

user257 gravatar imageuser257 ( 3 years ago )

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: 3 years ago

Seen: 184 times

Last updated: Jan 10 '22