Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I have problem in Mathematica with unnecessary rounding which is caused by high precision. For example I have value a = 2.052685846*10^-1865, when I make b = 1 - a the result is b == 1.
What can I do to have a better precision, without rounding?

share|improve this question
1  
Works for me, but I'm on 9.0.1. Don't imagine any major differences here between versions - are your examples exactly what you're using? –  rasher Mar 21 at 9:04
    
@rasher Yes, it is EXACTLY the same. So as you can see, there must be a difference. Or maybe I can change seetings to have better precision? –  Ziva Mar 21 at 9:12
    
Are you sure you didn't write b = 1. - a? The decimal point after the 1 makes all the difference. –  m_goldberg Mar 21 at 16:32
1  
Considering Mr.Wizard's answer, I don't think this question should be closed. –  Michael E2 Mar 22 at 1:35
add comment

2 Answers 2

up vote 2 down vote accepted

Works for me on Mathematica 8.0.
however, you can try using N to have the value number with the number of significant digits as you like:

b = N[ 1-a, 2000]

$2000$ digits after the decimal point in this case Mathematica does not perform rounding to $1$.

share|improve this answer
    
@Ziva N[ 1-a, 2000] yields the same result as 1 - a for me (V9.0.1, 8.0.4, 7.0.0). I don't get 2000 digitsl I get 1880 plus 27 insignificant digits. –  Michael E2 Mar 22 at 1:34
add comment

I suspect that there may be an issue of $MaxMachineNumber in play here. On my machine $MaxMachineNumber is 1.79769*10^308 therefore:

MachineNumberQ[a = 2.052685846*10^-1865]

Precision[1 - a]
False

1880.64

This means that 1 - a is done with arbitrary precision arithmetic and all digits are displayed. However if a smaller exponent is used such that a is machine size only machine precision arithmetic will be used, and the result is 1.:

MachineNumberQ[a = 2.052685846*10^-186]  (* note -186 *)

1 - a

Precision @ %
True

1.

MachinePrecision
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.