"ustunozgur" <ustunozgur@gmail.com> wrote in message
news:7e2e0d2d-b779-4137-92f5-
>
> Howcome? What is the best way to deal with such large numbers in
> MATLAB? How can I see the number without num2str function?
>
> Best regards,
>
> Ustun
(but then you are stuck with the symbolic domain and can't use other Matlab
numeric functions, or use large numbers package as "Variable Precision
Integer Arithmetic" in file exchange, or work with the logs of the numbers
instead of the numbers themselves.
ustunozgur <ustunozgur@gmail.com> wrote in message <7e2e0d2d-b779-4137-92f5-8b4b2807764f@g23g2000yqh.googlegroups.com>...
> a = 100^100; str2num(num2str(a)) == a
>
> results in 1
>
> but
>
> num2str(a) =
> 99999999999999996973312221251036165947450327545502362648241750950346848435554075
> 53419633840470625186802751241597388240818213573436827848463938504104723987787102
> 3591066789981811181813306167128854888448
>
>
> Howcome? What is the best way to deal with such large numbers in
> MATLAB? How can I see the number without num2str function?
>
You're dealing with floating-point roundoff. The result you're getting from
num2str is O(eps) different than 100^100, in terms of relative error.
If you need a 200+ digit number, with all digits represented, don't use floating-point.
Use VPA.
x = vpa ('100^100', 210)
Alternatively, use fprintf
fprintf ('%32.18g\n', 100^100);
which reports 1e+200.
Tags for this Thread
Add a New Tag:
Separated by commas
Ex.: root locus, bode
What are tags?
A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.
Anyone can tag a thread. Tags are public and visible to everyone.
NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for
all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content.
Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available
via MATLAB Central.
Read the complete Terms prior to use.