Operator in C: not greater and equal to.
Solution 1
Just change it to (f < i) which is !(f >= i).
Note: this is not the case if either f or i is NaN. This is because f >= i will evaluate to false if either is NaN leading to !(f >= i) evaluating to true where f < i evaluates to false.
Solution 2
You want to do: if (!(f>=0))...
Specific to what you're doing, using < makes more sense. My suggestion here is just for a generic means of reversing polarity on any if statement.
Solution 3
Not greater than or equal to is equivalent to less than.
Solution 4
Use the aliter i.e instead of !> think in reverse and use f<i
and you cant use ! for more than one operator i.e !+= is not valid
Unknown
Updated on July 09, 2022Comments
-
Unknown 3 monthsJust a fast question:
I'm trying to test if a variable is not greater than or equal to another variable.
I have it coded as such:
if (f!>=i){ print ("True");}but my c compiler won't recognize it. I can't find it online, is it possible?
-
chris almost 10 years! is a unary operator. It has to be applied to one thing, so think of what that one thing should be. -
Unknown almost 10 yearsYou're going to have to expand on that. -
Lee Taylor almost 10 yearsUm, isn't that the same asif(f<i)? -
Fantastic Mr Fox almost 10 years@LeeTaylor Yep, that is the answer that everyone below has provided. -
David Schwartz almost 10 yearsYou're in luck! C has a "not greater than or equal to" operator. It's called "less than". -
Daniel Fischer almost 10 yearsIt's unlikely to be important for your use case, but the pedant in me is compelled to note thatf < iis not equivalent to!(f >= i)if a NaN is involved. A comparison with a NaN always returns 0 (false). -
mah almost 10 years@PeterO. What does this question have to do with the comma operator? Perhaps you mis-linked the possible duplicate? -
Peter O. almost 10 years@mah: Guess you're right. Unfortunately, I can't take back my vote to close.
-
-
wizzwizz4 over 5 yearsThis is not correct, as it will be true foranyvariablename == 0which is unwanted. -
Sophie over 3 yearsPlease note thata < bis not the same as!(a >= b)for floating point types if either value was NaN.