• Welcome to Overclockers Forums! Join us to reply in threads, receive reduced ads, and to customize your site experience!

A little beta testing

Overclockers is supported by our readers. When you click a link to make a purchase, we may earn a commission. Learn More.

JigPu

Inactive Pokémon Moderator
Joined
Jun 20, 2001
Location
Vancouver, WA
I've nearly finished re-writing my prime number program in C++, and would like you guys to do some beta testing for me. I've gotten out most of the bugs I can find, but you never know until others run the thing. Any comments or suggestions on my program and code are welcomed.


Known bugs:
- Does not count '2' as prime. Thus, any lists from 2 or below will not display it or count it in it's statistics.
- If a run is interrupted, then started again with the continue file, statistics will be shown ONLY for the primes found in the current session.

JigPu
 

Attachments

  • primes.zip
    83.3 KB · Views: 59
I would put a Press Any Key to Continue ... thing at the end so that it doesn't close immediately after displaying the primes. Yeah ... if you open the program through the command line it doesn't close the window, but thats annoying.

I didn't find any bugs.
 
I tried it up to 1 million. It gave the same number of primes (minus 1) as my primes program. I also checked the last 20 numbers and they were the same. So, if you have a mistake, I have the same mistake.

Looking over your code I was surprised to see double instead of __int64. int64 should be faster and have a greater range. Although it will only make a difference for correctness for numbers larger than 2^42. I'm not sure how long it will take your algorithm to run that.

If you want you can check out my primes program here. It uses unsigned __int64, but I did the get_primes function as a template so any suitable type could be subsituted.
 
I would use __int64 by default since it is a lot faster for smaller numbers, but I sometimes end up listing primes in the trillions where double is significantly faster.


I just did a test with __int64 to try to shave off some time on a 1-Million, but it ended up giving me nil (or worse times :eek: ). Something has to be up as I know that in several of my versions before this __int64 would run about 2x faster times on my computer. Since it's not part of the "official" program it's not technically a bug, but definatly needs looking into ... Time for some research :)

JigPu
 
Last edited:
Back