Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
NCTM or The Math Forum.
|
|
Math Forum
»
Discussions
»
Software
»
comp.soft-sys.matlab
Notice: We are no longer accepting new posts, but the forums will continue to be readable.
Topic:
How do you get Matlab to recognize 1000 digit numbers without rounding?
Replies:
2
Last Post:
Jan 7, 2013 10:31 AM
|
 |
|
|
Re: How do you get Matlab to recognize 1000 digit numbers without rounding?
Posted:
Jan 7, 2013 10:31 AM
|
|
"Allen " <calderwoodra@vcu.edu> wrote in message news:kcah58$h8s$1@newscl01ah.mathworks.com... > 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 slord@mathworks.com To contact Technical Support use the Contact Us link on http://www.mathworks.com
|
|
|
|