Thread: -= operation (minGw)

  1. #1
    Registered User
    Join Date
    Feb 2008
    Posts
    58

    Question -= operation (minGw)

    Hi

    I am using the -= operation on a uint8_t number but when I debug / execute the number does not reduce by the value I give it, done anyone know why?

    Code:
    uint8_t number;
    
    number = 15;
    
    number -= 13;
    ...

    Number still equals 15?!?

    thanks

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Provide the smallest and simplest compilable code that demonstrates the problem. Chances are, you made a mistake elsewhere.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    My first guess would be simple oversight on your behalf.

    Example:
    Code:
    int main(void)
    {
      int number = 15;
    
      printf("number = %d\n", number);
      
      number -= 13;
      printf("number - 13 = %d\n", number);
    
      getchar();  
    
      return 0;
    }
    Something like that should work, if not then feel free to post back.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. i=++i; operation undefined?
    By password636 in forum C Programming
    Replies: 10
    Last Post: 04-16-2009, 09:46 AM
  2. how to change this simple opeation into power operation..
    By transgalactic2 in forum C Programming
    Replies: 9
    Last Post: 12-20-2008, 03:17 PM
  3. Replies: 5
    Last Post: 12-04-2008, 08:15 PM
  4. Replies: 16
    Last Post: 11-23-2007, 01:48 PM
  5. Serial Communications in C
    By ExDigit in forum Windows Programming
    Replies: 7
    Last Post: 01-09-2002, 10:52 AM