Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: How does it look?

  1. #1

    How does it look?

    Program I just started work on as a bit of practice for seeing how well the user's CPU handles big time load. It's not complete yet, but do you guys think the code so far will work out? Or shall the C++ gods shun me for creating a program with bad syntax?




    Code:
    /* Disclaimer:
    *** I am NOT responsible for ANY damage to your CPU or other computer components
    *** WHATSOEVAR if you compile this program and run it. This applies to any
    *** computer that this is run on. If you don't think your computer can handle it,
    *** then the simple answer is: Don't compile and run this program!*/
    
    
    
    #include <iostream.h>
    #include <string.h>
    
    //The variables that will be used:
    
    float fltCpuCrunching = "0.2374103572389719948327591531"
    int nTrillion = "100000000000"
    string szY "Y"
    string szTheAnswer
    int main()
    
     {
         cout<<
               "This program will test out your CPU big time. It's advised you have/n";
         cout << "a good heatsink and fan. If you're on a Dell, it's not advised you run this/n";
         cout << "for risk of overheating your CPU, as most Dells lack a fan on the HS./n";
         
         cout << "Ok, type Y to continue... ";
         cin >> szTheAnswer;
          
          switch (szTheAnswer)
          {
              case 'y' : cout<<
                               "Are you ready to ruuuuuuuumbleeeee?"; goto burnination; break;
              case 'n' : cout<<
                               "Goodbye."; goto end; break
              default : cout<<
                              "Try again. Press /'Y'/ this time, ok? ";
    Tell me if you think I\'m spamming or doing something stupid, please.

  2. #2
    Me thinks you be missing a bit of code there, ehh?

  3. #3
    Lol, yes, I need to work the actual burnination into it. I'll get to that right now.




    EDIT: Ok, here's what I've got on it so far. I'm tired, so please don't yell at me too much for the pseudo-code.


    Code:
    /* This will be the burnination part of the main program. Tweak it as you wish
    *** And, oh yea, If you could help me out on the loops... =D! */
    
    
    
    //OK! IT'S PSEUDOCODE! STFU ALREADY!
    
    while (nMainNumber < nTrillion)
     fltCpuCrunching x 2, nMainNumber++
     cout<< "We're at: " fltCpuCrunching " right now.../n"
    Tell me if you think I\'m spamming or doing something stupid, please.

  4. #4
    Senior Member
    Join Date
    Jul 2003
    Posts
    813
    As a simple advice I would say avoid goto labels and use functions instead. Especially since your program can integrate them easily.

    And printing out the current seed with text is kind of a pointless venture. Just print out the seed and it should suffice.

    Oh and... int up to a trillion? You need to review your data types Data-type string won't work because you haven't included the correct header. Also the variable szY is pointless this far... and if you ask me, I would stick to char types.

    Also why not use double instead of float? IIRC your variable would get some digits taken off anyway... Just a few hints.
    /\\

  5. #5
    Thanks for the advice, hypronix. Yea, I'm still learning C++, so I'm doomed to make mistakes... the C++ gods dislike me...




    I'll work into getting some of what you said into the program. And thanks again for reminding me about the char variable... like I said, I make stupid mistakes.
    Tell me if you think I\'m spamming or doing something stupid, please.

  6. #6
    Custom User
    Join Date
    Oct 2001
    Posts
    503
    I'm not incredibly certain that this program would actually stress your CPU in any way. No matter how many decimal places your number has, I'm sure the cpu can multiply it by 2 fine. And you're missing loads of ";"s (the var declarations at the start)

    But you might as well code it any way for the fun of it, and if it does do something brilliant by the time you've finished...amazing.

    [edit] Something picky: Putting "x"s even in pseudo code (when meaning multiply) is a bit confusing (for me at least). I would still use "*" if I were you because I had to stare at your code for a second trying to figure out what you meant (just expected *). Obviously it's different when you're writing something by hand, but when it's in ascii, it's a bit difficult to understand sometimes (very occasionally :P) [/edit]

    ac

  7. #7
    Senior Member
    Join Date
    Jul 2001
    Posts
    420
    Originally posted here by gothic_type
    I'm not incredibly certain that this program would actually stress your CPU in any way. No matter how many decimal places your number has, I'm sure the cpu can multiply it by 2 fine. And you're missing loads of ";"s (the var declarations at the start)

    But you might as well code it any way for the fun of it, and if it does do something brilliant by the time you've finished...amazing.

    [edit] Something picky: Putting "x"s even in pseudo code (when meaning multiply) is a bit confusing (for me at least). I would still use "*" if I were you because I had to stare at your code for a second trying to figure out what you meant (just expected *). Obviously it's different when you're writing something by hand, but when it's in ascii, it's a bit difficult to understand sometimes (very occasionally :P) [/edit]

    ac
    I very much agree. I think you might stress the OS but not the CPU. I saw some interesting errors on w95 when I played with overflow and underflow. snippets like:

    int i;
    for ( i=0; i&gt;0; i++)
    {
    //empty loop it will still cause overflow
    }
    printf("Overflow value is %d\n", i);
    //underflow can be done the same just turn &gt; to &lt; make the ++ into --

    Have not run the above for sometime. It effectly stop the OS from working has intended. It is possible that ms has since changed the way the OS response to over/under flows.

    Cheers,
    Duncan
    If you spend more on coffee than on IT security, you will be hacked. What\'s more, you deserve to be hacked.
    -- former White House cybersecurity adviser Richard Clarke

  8. #8
    Senior Member
    Join Date
    Dec 2003
    Location
    Pacific Northwest
    Posts
    1,675
    Kamikaze

    Just a little info on data types and integers to toy with:

    In the 32 bit environment integers can range from –2,147,483,648 to the opposite minus one of course: 2,147,483,647.

    And always float, double, and long double, can really hold large values, float = 7 digits, double = 15 digits , and long double = 19 digits, so that is probably where you'd be heading.

    c/c++ only sets the lower of each data type, not its size in bytes and of course your complier comes in to play as well. It specifies the range/size of the types found in your header &lt;climits&gt;. So your complier may not accept your code and if it does your computer may not be able run it. But what the heck, here's what "long" looks like: 8 bytes, -9223372036854775808 to 9223372036854775807


    cheers
    Connection refused, try again later.

  9. #9
    T3h 1337 N00b kryptonic's Avatar
    Join Date
    Sep 2003
    Location
    Seattle, Washington.
    Posts
    523
    /me heads off to compile and test out.

  10. #10
    Senior Member
    Join Date
    Jul 2003
    Posts
    813
    That's true about data types. The signed ones. But why not kick it up a notch and go unsigned... as far as this program's concerned it would simply display nicer from 0 to the top value.

    I think the screen output is rather pointless, but it does add into the 'stress'... I would make it check for values every 1,000,000 seeds or something, just as an indication that the program's still working.
    /\\

Posting Permissions

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