1
$\begingroup$

Let

x= 0.0000000000000000036;

y = 1 - x

If i type this in Mathematica the answer of y is 1. I want the answer to be as it is 0.9999999999999999964

$\endgroup$
4
  • $\begingroup$ x=1/277777777777777769... or as inexact but showing digits 1 - 0.0000000000000000036`2 $\endgroup$
    – ciao
    Jul 5, 2014 at 21:31
  • $\begingroup$ @rasher. Mathematica rounds it up to unity istead of showing me the answer 0.9999999...64 $\endgroup$
    – Nikolas
    Jul 5, 2014 at 21:37
  • $\begingroup$ If you're on pre- 9.x, you might need to change the "displayed precision" option under "appearance->Formatting" in preferences. Try adding //InputForm to the end of your calculation, see what you see... If you're using N to convert exact to inexact, make sure you specify enough precision in it. $\endgroup$
    – ciao
    Jul 5, 2014 at 21:44
  • $\begingroup$ @rasher. Neither work. I set the displayed precision to 20decimal and still the same. Also //InputForm does not change anything $\endgroup$
    – Nikolas
    Jul 5, 2014 at 21:48

2 Answers 2

2
$\begingroup$
    x = SetPrecision[0.0000000000000000036, 1];
    y = 1 - x

(*0.9999999999999999964*)
$\endgroup$
3
  • $\begingroup$ Works Great! thanks :) $\endgroup$
    – Nikolas
    Jul 5, 2014 at 21:55
  • 1
    $\begingroup$ with little less typing "x =0.0000000000000000036`1"; $\endgroup$
    – Nasser
    Jul 5, 2014 at 22:00
  • $\begingroup$ @Nasser. It is not my code. It is a part of it and the number comes from other equations and changing variables. I simplified the question. $\endgroup$
    – Nikolas
    Jul 5, 2014 at 22:03
2
$\begingroup$

Amplifying on Algohi's answer

Table[{
   x = SetPrecision[0.0000000000000000036, n],
   Precision[x],
   1 - x,
   Precision[1 - x]},
  {n, 10}] // Grid

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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