The Mathematica Journal
Download This Issue
Feature Articles
Graphics Gallery
Tricks of the Trade
In and Out
The Mathematica Programmer
New Products
New Publications
News Bulletins
Editor's Pick
Write Us
About the Journal
Staff and Contributors
Back Issues

Setting Precision in Binary Digits

Q: I would like to specify the precision of my numbers in binary digits rather than decimal digits. Is there any way of doing this?
A: Rob Knapp ( answers: The precision of numbers in Mathematica is kept as a real quantity. This means that you can easily specify a precision in binary digits by multiplying it by [Graphics:../Images/index_gr_107.gif]. For example, here we specify [Graphics:../Images/index_gr_108.gif] to 20 binary digits.
Using FullForm gives you the fractional (with respect to base 10) precision.
By default, Precision rounds to the nearest integer.

In Mathematica 4 there is an option to prevent this rounding.

If we examine the RealDigits of n in base 2,
we see that there are 20 binary digits.
Another way to display the same information is using BaseForm.
You can enter a number in an arbitrary base using base^^digits see Sections 3.1.3 and A.2.5 of The Mathematica Book).
The result is identical to that obtained using SetPrecision.

Converted by Mathematica      September 29, 1999 [Prev Page][Next Page]