Thread: Very elementary C++ question

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Oct 2006
    Posts
    26
    Oh, okay. So what does the <= operator do in that context?

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by Dondrei View Post
    Oh, okay. So what does the <= operator do in that context?
    Exactly what you would expect from that expression : compares if the result of (a <= b) [which is either 0 or 1] is greater or equal to c.

    The problem is that you didn't want to compare if the boolean value of (a <= b) is greater or equal to c, you wanted to compare if c is greater or equal to b as well as a <= b.

    --
    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
    Oct 2006
    Posts
    26
    I think I'll just separate with &&s, probably the simplest way.

    Quote Originally Posted by matsp View Post
    Exactly what you would expect from that expression : compares if the result of (a <= b) [which is either 0 or 1] is greater or equal to c.

    The problem is that you didn't want to compare if the boolean value of (a <= b) is greater or equal to c, you wanted to compare if c is greater or equal to b as well as a <= b.

    --
    Mats
    Ah, that makes sense.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Debugging question
    By o_0 in forum C Programming
    Replies: 9
    Last Post: 10-10-2004, 05:51 PM
  2. Question about pointers #2
    By maxhavoc in forum C++ Programming
    Replies: 28
    Last Post: 06-21-2004, 12:52 PM
  3. Question...
    By TechWins in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 07-28-2003, 09:47 PM
  4. Question about linked lists.
    By cheeisme123 in forum C++ Programming
    Replies: 6
    Last Post: 02-25-2003, 01:36 PM
  5. Question, question!
    By oskilian in forum A Brief History of Cprogramming.com
    Replies: 5
    Last Post: 12-24-2001, 01:47 AM