Results 1 to 12 of 12

Thread: "arithmetic exception"

  1. #1
    PC Aficionado MJCfromCT's Avatar
    Join Date
    Jun 2003
    Posts
    4,726

    "arithmetic exception"

    Hi all,

    A friend of mine has written a program to calculate the first 10000 prime numbers...consider it a benchmark of sorts (trying to see if my pc or his mac is better ). Here is the source code, but whenever we try to calculate more than 2 prime numbers, we get an error. Any advice? Thanks in advance

    I attached the code, but its a .txt file...if you just want to copy and paste it into a compiler and execute, i'd appreciate it.

    The program was created on a mac, ran fine on there, but cannot run on gcc or in visual studio
    Attached Files Attached Files

  2. #2
    Member frnkzks's Avatar
    Join Date
    Jun 2001
    Location
    Maryland
    Posts
    170
    ......

    primeBank = malloc( searchCount * sizeof( uint32_t ) );

    ......

    primeCount = 0;



    Do you see anything wrong with this?

  3. #3
    Banned qball's Avatar
    Join Date
    Oct 1999
    Location
    Rockaway, NJ 07866
    Posts
    1,730
    ...consider it a benchmark of sorts...
    or not.

    maybe you found the "benchmark" Apple used to denote the g5:

    "the fastest PC...ever."

  4. #4
    PC Aficionado MJCfromCT's Avatar
    Join Date
    Jun 2003
    Posts
    4,726
    ...this is not a g5 machine...its a g4 laptop vs. a 2700+ desktop. we are benchmarking basic low level stuff like mathematical computations to see who's computer is more effective

    ...we want to write our own program to determine whos is more effective...its a simple .c file that can be compiled on both machines, ran, and have the results compared...with regard to the "fastest pc ever", I dont think they'd say "Its pretty fast, but boy does AMD got us in this one..." We want to find out for ourselves

  5. #5
    Banned qball's Avatar
    Join Date
    Oct 1999
    Location
    Rockaway, NJ 07866
    Posts
    1,730
    are you trying to benchmark?

    or write a program that calcs:

    "the first 10000 prime numbers"

    ???

  6. #6
    Gone Fishin' ukulele's Avatar
    Join Date
    Aug 2001
    Location
    Southern Most Point in US
    Posts
    6,260
    You can not divide a number by zero. End of story. If your loop control begins with zero and is also part of the equation you have a arithmetic error.

  7. #7
    PC Aficionado MJCfromCT's Avatar
    Join Date
    Jun 2003
    Posts
    4,726
    qball,

    wouldn't calculating the first 10,000 prime numbers benchmark the processors of each machine by telling how long it took to get there?

    *problem solved* The problem was traced down to an error with displaying the prime numbers to the screen...once this was enabled, everything ran fine...fyi the 2700+ was 33% faster than the g4 1ghz at calculating the prime numbers

  8. #8
    Banned qball's Avatar
    Join Date
    Oct 1999
    Location
    Rockaway, NJ 07866
    Posts
    1,730
    wouldn't calculating the first 10,000 prime numbers benchmark the processors of each machine by telling how long it took to get there?
    [disregard]
    you should answer, or attempt to answer some of
    my questions?
    [/disregard]

    regardless, to answer that ?:

    NO, as, depends on how you determine '10,000 prime numbers'. As Nth prime numbers is a known algorithm, NO.

    as far as benchmarking, ask yourself a few ???s

    which one starts faster.
    which one shutdown faster.
    which one net connects faster.

    would you trade?
    which one do you like?

  9. #9
    Member Dark_Raver's Avatar
    Join Date
    Sep 2001
    Location
    Not in a worm enough spot
    Posts
    231
    plus if you wanted to simply compare processing power than wouldn't displaying the numbers change the result??

    you are after all interfacing with other hardware.

  10. #10
    Banned qball's Avatar
    Join Date
    Oct 1999
    Location
    Rockaway, NJ 07866
    Posts
    1,730
    ...wouldn't displaying the numbers change the result...
    perhaps? but if each has to display, seems fair enough.

    benchmarking is something most understand, but is not easy. benchmarking a PC is like asking, "what is the best car?"

  11. #11
    PC Aficionado MJCfromCT's Avatar
    Join Date
    Jun 2003
    Posts
    4,726
    we still have not figured out why the mac g4 was able to run the "benchmark" program without displaying the numbers without a hitch, while the AMD machine coudln't...we tried it on an intel box, and instead of an arithmetic exception, we got a floating point error...so we are assuming that it is a processor-dependent thing, perhaps the g4 is more forgiving in this case....regardless of which, it worked on both machines with displaying the numbers as they were calculated...the AMD machine ended up being about 33% faster...but considering the AMD was a 2700+ and the g4 was a 1ghz processor, 33% isn't too spectacular...

    qball,
    its hard to answer "what is the best car", but you can answer questions like "what car does 0-60 the quickest" or "which car taks the shortest distance to brakefrom 100mph"....what we were trying to ask was "which car can go from 0-10000 prime numbers the fastest" Right now we are considering other ways that we can test these computers to continue the benchmarks we have started....thank you all for the advice given

  12. #12
    Banned qball's Avatar
    Join Date
    Oct 1999
    Location
    Rockaway, NJ 07866
    Posts
    1,730
    ..and instead of an arithmetic exception, we got a floating point error...
    they are the same.

    you have a variable in your program that:

    gets too big for "memory allocated".

    qball,
    its hard to answer "what is the best car"
    no, it is not. just a matter of opinion.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •