MATLAB Answers

How to write vector form of very large number?

5 views (last 30 days)
manoj subedi
manoj subedi on 10 Jan 2020
Commented: Stephen Cobeldick on 10 Jan 2020
I have to deal with very large numbers like 99^99.
I want these numbers in the vector form. For example, for 5^5=3125 , I should be able to write this in the form {3, 1, 2, 5}
Though the method with sprintf works for some smaller number but num2str-'0' gives negative numbers ?

  0 Comments

Sign in to comment.

Answers (2)

David Hill
David Hill on 10 Jan 2020
You could always use java BigInteger if you don't have symbolic toolbox.
import java.math.*
x=BigInteger(99);
x=x.pow(99);
x=char(x)-'0';

  0 Comments

Sign in to comment.


Walter Roberson
Walter Roberson on 10 Jan 2020
John D'Errico has a Variable Precision Integer contribution in the file exchange.
Or you use symbolic toolbox if you have that.

Sign in to answer this question.


Translated by