
dbaugh
New User
Oct 24, 2011, 9:30 PM
Post #1 of 2
(576 views)
|
Hi, This is my first post on this forum. Be gentle. I am reading hundreds of millions of 12 digit numbers from files. I then square the numbers and keep a counter of how many I have read in. When I get an interesting result, like the last number in a given file or the millionth number, I square it and add it to a 24 digit constant. I then print the result to the screen along with the count so far. As an aside, I would prefer to write it to a file, but I can probably figure that out. Perl does all of this very quickly. The results are wrong. If I put in a use BigInt the results are correct and the speed slows to a crawl. I think it is probably treating every variable like it is a big integer when I only need it for the squared sum and certainly not for the running count. How do I only suffer the speed penalty of BigInt where it is necessary? Or, is there an entirely different better way to do this? Thanks, David
|