Loss of Precision and For Loops

2 views (last 30 days)
My program has to preform a task an N-factorial number of times. Besides the obvious problems involving computational time, I was wondering how the loss of precision of very large numbers affected the number of times that my program went through the loop. If I have a number like 25 factorial, it doesn't have accuracy down to the ones place. So if I needed my program to run through a process 25! times, would it actually attempt to do it 25!, or would it round off somewhere?
So if I wrote
for i = 1 : factorial ( 25 )
would the loop run through 25! times or would it round down to another number?

Accepted Answer

Walter Roberson
Walter Roberson on 1 Apr 2013
It would round it off.
... You do realize that it would require approximately half a billion years if you were able to operate at 1 billion iterations per second ????
  1 Comment
Juan
Juan on 2 Apr 2013
Edited: Juan on 2 Apr 2013
Yeah, I eventually sat down to do the math and I saw it was unfeasible. I kinda figured out that the time would be ridiculous, although I never thought it would be in the order of a billion years. I was just curious about rounding though.
Thanks!

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!