+ Post New Thread
Results 1 to 4 of 4
  1. #1
    Full Member level 4
    Points: 1,731, Level: 9
    rparthiban69's Avatar
    Join Date
    Aug 2012
    Posts
    225
    Helped
    19 / 19
    Points
    1,731
    Level
    9

    I have doubt in basic c

    what is the meaning of this function?

    if((X>255) || (X<0))
    Thanks,
    Parthi

    •   AltAdvertisment

        
       

  2. #2
    Advanced Member level 4
    Points: 7,943, Level: 21
    Achievements:
    7 years registered
    paulfjujo's Avatar
    Join Date
    Jun 2008
    Location
    France 01120
    Posts
    1,299
    Helped
    263 / 263
    Points
    7,943
    Level
    21

    Re: I have doubt in basic c

    hello

    Tell us before , how X is defined ?

    unsigned char
    signed char
    int
    unsigned int



    •   AltAdvertisment

        
       

  3. #3
    Super Moderator
    Points: 76,699, Level: 67
    Achievements:
    7 years registered
    Awards:
    2nd Helpful Member
    betwixt's Avatar
    Join Date
    Jul 2009
    Location
    Aberdyfi, West Wales, UK
    Posts
    12,547
    Helped
    4182 / 4182
    Points
    76,699
    Level
    67

    Re: I have doubt in basic c

    If X is an 8-bit value it can't be more than 255 and a check for less than zero is meaningless if it's an unsigned value so I'm guessing it's an 'int' (signed).

    It isn't a function in the programming sense, it's a query. It reads as "if the value of X is more than 255 or the value of X is less than zero". It means the following code will only be executed if X isn't between 0 and 255.

    Brian.
    PLEASE - no friends requests or private emails, I simply don't have time to reply to them all.
    It's better to share your questions and answers on Edaboard so we can all benefit from each others experiences.



    •   AltAdvertisment

        
       

  4. #4
    Banned
    Points: 23,048, Level: 36

    Join Date
    Dec 2012
    Location
    Bangalore, India
    Posts
    4,294
    Helped
    830 / 830
    Points
    23,048
    Level
    36

    Re: I have doubt in basic c

    As mentioned by others it depends on the size of X. If X is unsigned int its range is 0 to 65535. The Conditional statement check if X > 255 or X < 0. If any of the 2 condition X > 255 or X < 0 is true then the if condition will be true and the if statement will be executed.



--[[ ]]--