Drexel dragonThe Math ForumDonate to the Math Forum

Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.

Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: How do you get Matlab to recognize 1000 digit numbers without

Replies: 2   Last Post: Jan 7, 2013 10:31 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Steven Lord

Posts: 17,945
Registered: 12/7/04
Re: How do you get Matlab to recognize 1000 digit numbers without rounding?
Posted: Jan 7, 2013 10:31 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

"Allen " <calderwoodra@vcu.edu> wrote in message
> I am working on project Euler and one of the problems asks you to find the
> largest product of 5 consecutive numbers in a given 1000 digit number. My
> question is how do I input this number without Matlab rounding?

No 1000-digit number can be represented as a finite double precision value
(unless the first 700ish digits are 0.) They will all overflow to Inf
or -Inf. Use Symbolic Math Toolbox instead.

a = sym('123456789012345678901234567890')

Note that the quotes are NECESSARY otherwise MATLAB will interpret your
string of 1000 digits as a double then convert the resulting Inf into a
symbolic object.

Steve Lord
To contact Technical Support use the Contact Us link on

Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2015. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.