Group Abstract Group Abstract

Message Boards Message Boards

Set Precision- digits and rationals?

Posted 8 years ago

Hey guys,

I am bit confused with the Precision in Mathematica. I first set Precision at 50. Then I set up two tables one starts from 0.5 with gap 1/2 until 9 and the other starts from 1/2 with gap 1/2 until 9 too. However, the first table stops at 8.5 while the second one stops at 9. The key part focus on the difference between 8.5 with precision 51.23044892137827 and 8.5 with precision 50, the 17th item in each table. If you simply check by "==" then the answer is True. So I am wondering how to check their difference.

Please see my attachment. Commend are pasted in the following.

$PreRead = (# /. 
     s_String /; 
       StringMatchQ[s, NumberString] && 
        Precision@ToExpression@s == MachinePrecision :> s <> "`50." &);
T1 = Table[z, {z, 0.5, 9, 1/2}]
% // FullForm
T2 = Table[z, {z, 1/2, 9, 1/2}]
T1[[17]] == T2[[17]]

Thanks in advance.

Attachments:
POSTED BY: Zhehao Zhang
2 Replies
Posted 8 years ago
POSTED BY: Updating Name
Posted 8 years ago

Sorry, I am still bit confused.

If you run my notebook, you will find the first table ends with 8.5'51.23 while the second table sends with 9. I am wondering what leads to the difference. As you said, if 8.5'50 are exactly the same as 8.5'51, then why does the last number disappear in the first table?

POSTED BY: Zhehao Zhang
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard