Like Tree1Likes
  • 1 Post By m37h0d

Arithmetic

This is a discussion on Arithmetic within the C++ Programming forums, part of the General Programming Boards category; I want to get a positive value. Can I get it in a simpler way? Code: int iMinutes = 15; ...

  1. #1
    Registered User
    Join Date
    Dec 2007
    Location
    France
    Posts
    747

    Arithmetic

    I want to get a positive value. Can I get it in a simpler way?

    Code:
        int iMinutes = 15;
        iMinutes -= 60;
        iMinutes *= -1;
    
        cout << iMinutes << endl;
    Compiler MSVC++ 2010 with Code::Blocks.

  2. #2
    3735928559
    Join Date
    Mar 2008
    Location
    RTP
    Posts
    839
    int minutes = 45;

    or

    int minutes = 15;
    minutes = 60-minutes;

    you really shouldn't have to ask this, should you? O_o
    Ducky likes this.

  3. #3
    Registered User
    Join Date
    Dec 2007
    Location
    France
    Posts
    747
    No I shouldnt.
    Thanks!
    Compiler MSVC++ 2010 with Code::Blocks.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Arithmetic Help
    By cduce2411 in forum C++ Programming
    Replies: 3
    Last Post: 03-18-2009, 11:58 AM
  2. arithmetic
    By shuo in forum C++ Programming
    Replies: 1
    Last Post: 01-20-2008, 04:29 PM
  3. arithmetic help
    By freeindy in forum C Programming
    Replies: 10
    Last Post: 09-18-2007, 08:01 AM
  4. arithmetic without variables?
    By manutdfan in forum C Programming
    Replies: 5
    Last Post: 10-30-2006, 02:34 AM
  5. mod arithmetic in C++
    By Unregistered in forum C++ Programming
    Replies: 2
    Last Post: 01-10-2002, 11:59 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21