<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/264639</link>
    <title>MATLAB Central Newsreader - 100^100 != 100^100</title>
    <description>Feed for thread: 100^100 != 100^100</description>
    <language>en-us</language>
    <copyright>&amp;copy;1994-2012 by MathWorks, Inc.</copyright>
    <webmaster>webmaster@mathworks.com</webmaster>
    <generator>MATLAB Central Newsreader</generator>
    <docs>http://blogs.law.harvard.edu/tech/rss</docs>
    <ttl>60</ttl>
    <image>
      <title>MathWorks</title>
      <url>http://www.mathworks.com/images/membrane_icon.gif</url>
    </image>
    <item>
      <pubDate>Sat, 31 Oct 2009 12:05:16 -0400</pubDate>
      <title>100^100 != 100^100</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/264639#691153</link>
      <author>ustunozgur</author>
      <description>&amp;nbsp;a = 100^100; str2num(num2str(a)) == a&lt;br&gt;
&lt;br&gt;
results in 1&lt;br&gt;
&lt;br&gt;
but&lt;br&gt;
&lt;br&gt;
num2str(a) =&lt;br&gt;
99999999999999996973312221251036165947450327545502362648241750950346848435554075&lt;br&gt;
53419633840470625186802751241597388240818213573436827848463938504104723987787102&lt;br&gt;
3591066789981811181813306167128854888448&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
Howcome? What is the best way to deal with such large numbers in&lt;br&gt;
MATLAB? How can I see the number without num2str function?&lt;br&gt;
&lt;br&gt;
Best regards,&lt;br&gt;
&lt;br&gt;
Ustun</description>
    </item>
    <item>
      <pubDate>Sat, 31 Oct 2009 12:21:50 -0400</pubDate>
      <title>Re: 100^100 != 100^100</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/264639#691158</link>
      <author>Nasser M. Abbasi</author>
      <description>&lt;br&gt;
&quot;ustunozgur&quot; &amp;lt;ustunozgur@gmail.com&amp;gt; wrote in message &lt;br&gt;
news:7e2e0d2d-b779-4137-92f5-&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; Howcome? What is the best way to deal with such large numbers in&lt;br&gt;
&amp;gt; MATLAB? How can I see the number without num2str function?&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; Best regards,&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; Ustun&lt;br&gt;
&lt;br&gt;
either use symbolic as in&lt;br&gt;
&lt;br&gt;
a=sym(99999999999999996973312221251036165947450327545502362648241750950346848435554075534196338404706251868027512415973882408182135734368278484639385041047239877871023591066789981811181813306167128854888448)&lt;br&gt;
&lt;br&gt;
(but then you are stuck with the symbolic domain and can't use other Matlab &lt;br&gt;
numeric functions, or use large numbers package as &quot;Variable Precision &lt;br&gt;
Integer Arithmetic&quot; in file exchange, or work with the logs of the numbers &lt;br&gt;
instead of the numbers themselves.&lt;br&gt;
&lt;br&gt;
--Nasser </description>
    </item>
    <item>
      <pubDate>Sat, 31 Oct 2009 13:05:04 -0400</pubDate>
      <title>Re: 100^100 != 100^100</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/264639#691163</link>
      <author>Tim Davis</author>
      <description>ustunozgur &amp;lt;ustunozgur@gmail.com&amp;gt; wrote in message &amp;lt;7e2e0d2d-b779-4137-92f5-8b4b2807764f@g23g2000yqh.googlegroups.com&amp;gt;...&lt;br&gt;
&amp;gt;  a = 100^100; str2num(num2str(a)) == a&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; results in 1&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; but&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; num2str(a) =&lt;br&gt;
&amp;gt; 99999999999999996973312221251036165947450327545502362648241750950346848435554075&lt;br&gt;
&amp;gt; 53419633840470625186802751241597388240818213573436827848463938504104723987787102&lt;br&gt;
&amp;gt; 3591066789981811181813306167128854888448&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Howcome? What is the best way to deal with such large numbers in&lt;br&gt;
&amp;gt; MATLAB? How can I see the number without num2str function?&lt;br&gt;
&amp;gt; &lt;br&gt;
&lt;br&gt;
You're dealing with floating-point roundoff.  The result you're getting from&lt;br&gt;
num2str is O(eps) different than 100^100, in terms of relative error.&lt;br&gt;
If you need a 200+ digit number, with all digits represented, don't use floating-point.&lt;br&gt;
Use VPA.&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;x = vpa ('100^100', 210)&lt;br&gt;
&lt;br&gt;
Alternatively, use fprintf&lt;br&gt;
&lt;br&gt;
fprintf ('%32.18g\n', 100^100);&lt;br&gt;
&lt;br&gt;
which reports 1e+200.</description>
    </item>
  </channel>
</rss>

