Thread: If command

  1. #1
    Registered User
    Join Date
    Nov 2008
    Posts
    3

    If command

    I would like to know usage of the If command. An example is,
    ************************************************** **************
    Code:
      varmult  = (mult > 0) ? (0) : (1);
    
      mult     = MIN(MAX(ABS(mult), 1), MAXMULT);
    
      if(mult == 1) varmult = 0;
    
      if(varmult) {
    
        varmult = MAX(1, (mult * 4) / 5);
    
        sigmult = mult/4./SIG2FW;
    
      }
    ************************************************** ***************

    what is the mean of the if(varmult) ?
    best wishes

    serkan

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    if(varmult) is a shorter way to write if(varmult != 0). In C and C++, any variable is "true" if it's non-zero, and "false" if it's zero.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  3. #3
    Registered User
    Join Date
    Nov 2008
    Posts
    3
    thank you very much Mats

    best wishes

    serkan

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 26
    Last Post: 07-05-2010, 10:43 AM
  2. problem with "touch" command in c program
    By Moony in forum C Programming
    Replies: 10
    Last Post: 08-01-2006, 09:56 AM
  3. Batch file programming
    By year2038bug in forum Tech Board
    Replies: 10
    Last Post: 09-05-2005, 03:30 PM
  4. Ping problem
    By bladerunner627 in forum C++ Programming
    Replies: 12
    Last Post: 02-02-2005, 12:54 PM
  5. exe files in -c- language
    By enjoy in forum C Programming
    Replies: 6
    Last Post: 05-18-2004, 04:36 PM