Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
big numbers

Subject: big numbers

From: Syed Galib

Date: 7 Jul, 2009 12:14:02

Message: 1 of 6

Hello all,

Can anybody tell me if I can have big numbers in MATLab like 2^(2^15) ?
If yes, is it possible to get a particular bit like 1234th bit of that number?

Please help me in this issue.

Thank you in advance.

Regards
Galib

Subject: big numbers

From: nor ki

Date: 7 Jul, 2009 12:33:03

Message: 2 of 6

"Syed Galib" <galib.cse@gmail.com> wrote in message <h2ve6a$pse$1@fred.mathworks.com>...
> Hello all,
>
> Can anybody tell me if I can have big numbers in MATLab like 2^(2^15) ?
> If yes, is it possible to get a particular bit like 1234th bit of that number?
>
> Please help me in this issue.
>
> Thank you in advance.
>
> Regards
> Galib

Hi Galib,

maybe the symbolic math toolbox can help you..

kinor

Subject: big numbers

From: John D'Errico

Date: 7 Jul, 2009 12:48:01

Message: 3 of 6

"Syed Galib" <galib.cse@gmail.com> wrote in message <h2ve6a$pse$1@fred.mathworks.com>...
> Hello all,
>
> Can anybody tell me if I can have big numbers in MATLab like 2^(2^15) ?
> If yes, is it possible to get a particular bit like 1234th bit of that number?
>
> Please help me in this issue.

N = 2^vpi(2^15)
N =
   1415461031044954789001553027744951601348130 ...
...
...
...
9958077541122668104633712377856

Roughly 10000 digits of this mess. I might extract
the 10000th binary digit as:

m = vpi(2)^9999;
rem(N/m,2)
ans =
   0

Find my vpi toolbox on the file exchange:

http://www.mathworks.com/matlabcentral/fileexchange/22725

John

Subject: big numbers

From: Syed Galib

Date: 7 Jul, 2009 13:19:01

Message: 4 of 6

Dear John,
Thank you for your msg. I tried to write n = vpi(2^15) to see, but MATLab is giving me error msg like this:

??? Error using ==> class
The CLASS function must be called from a class constructor.

Error in ==> vpi at 181
INT = class(INT,'vpi');
 
So, please, let me know how to solve this.
Thanks for your help.

Galib

"John D'Errico" <woodchips@rochester.rr.com> wrote in message <h2vg61$7kv$1@fred.mathworks.com>...
> "Syed Galib" <galib.cse@gmail.com> wrote in message <h2ve6a$pse$1@fred.mathworks.com>...
> > Hello all,
> >
> > Can anybody tell me if I can have big numbers in MATLab like 2^(2^15) ?
> > If yes, is it possible to get a particular bit like 1234th bit of that number?
> >
> > Please help me in this issue.
>
> N = 2^vpi(2^15)
> N =
> 1415461031044954789001553027744951601348130 ...
> ...
> ...
> ...
> 9958077541122668104633712377856
>
> Roughly 10000 digits of this mess. I might extract
> the 10000th binary digit as:
>
> m = vpi(2)^9999;
> rem(N/m,2)
> ans =
> 0
>
> Find my vpi toolbox on the file exchange:
>
> http://www.mathworks.com/matlabcentral/fileexchange/22725
>
> John

Subject: big numbers

From: John D'Errico

Date: 7 Jul, 2009 13:34:01

Message: 5 of 6

"Syed Galib" <galib.cse@gmail.com> wrote in message <h2vi05$ajg$1@fred.mathworks.com>...
> Dear John,
> Thank you for your msg. I tried to write n = vpi(2^15) to see, but MATLab is giving me error msg like this:
>
> ??? Error using ==> class
> The CLASS function must be called from a class constructor.
>
> Error in ==> vpi at 181
> INT = class(INT,'vpi');
>
> So, please, let me know how to solve this.
> Thanks for your help.

You did not install it as you are supposed to do.
I do not know what you did, but I know that you
did something wrong.

Download the vpi toolbox.

Unzip it.

Put (ONLY) the top directory on your search path.
Do not put the @vpi directory on your search path.
Do not move any of the files in these directories from
their location when they were unzipped.

These are the rules whenever you download ANY
toolbox that defines a new class in MATLAB.

vpi(2)^2313
ans =
   19159314692567723173724158840516210991236
7555764611884510579632318196544229331976471
9577318473691655360871079958424008747136348
4900616418656869843998876457008714546423820
2479958904270472053169547608479612338476325
7186583353174619813845790959567083146241825
4075907936537958241635650100164280058572048
5651745566751439400940923028693501727625251
1712879260790135164572678816182114654946674
2946098943088693569989519826298022670623392
8723396644037308746011404444439693705213223
9648476955641251908979439130293166218247783
0466333940902860117202020769643603846552081
7926824832898154166165389041128984931197686
9297383235727641814482404486432763750018630
9018561824677717307410544547746013246097695
15559944192

John

Subject: big numbers

From: Syed Galib

Date: 7 Jul, 2009 14:33:01

Message: 6 of 6

Dear John,
I fixed the problem. let me check the other things..Thank you very much for your help.

Thanks.

Galib

"John D'Errico" <woodchips@rochester.rr.com> wrote in message <h2vis9$9f3$1@fred.mathworks.com>...
> "Syed Galib" <galib.cse@gmail.com> wrote in message <h2vi05$ajg$1@fred.mathworks.com>...
> > Dear John,
> > Thank you for your msg. I tried to write n = vpi(2^15) to see, but MATLab is giving me error msg like this:
> >
> > ??? Error using ==> class
> > The CLASS function must be called from a class constructor.
> >
> > Error in ==> vpi at 181
> > INT = class(INT,'vpi');
> >
> > So, please, let me know how to solve this.
> > Thanks for your help.
>
> You did not install it as you are supposed to do.
> I do not know what you did, but I know that you
> did something wrong.
>
> Download the vpi toolbox.
>
> Unzip it.
>
> Put (ONLY) the top directory on your search path.
> Do not put the @vpi directory on your search path.
> Do not move any of the files in these directories from
> their location when they were unzipped.
>
> These are the rules whenever you download ANY
> toolbox that defines a new class in MATLAB.
>
> vpi(2)^2313
> ans =
> 19159314692567723173724158840516210991236
> 7555764611884510579632318196544229331976471
> 9577318473691655360871079958424008747136348
> 4900616418656869843998876457008714546423820
> 2479958904270472053169547608479612338476325
> 7186583353174619813845790959567083146241825
> 4075907936537958241635650100164280058572048
> 5651745566751439400940923028693501727625251
> 1712879260790135164572678816182114654946674
> 2946098943088693569989519826298022670623392
> 8723396644037308746011404444439693705213223
> 9648476955641251908979439130293166218247783
> 0466333940902860117202020769643603846552081
> 7926824832898154166165389041128984931197686
> 9297383235727641814482404486432763750018630
> 9018561824677717307410544547746013246097695
> 15559944192
>
> John

Tags for this Thread

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.

Contact us