7

What do these operators do in D 2.0:

  • <>=
  • !<>=
  • !<=
  • !>=
3
  • When your title contains the whole question, chances are you want to be a bit more verbose in your question ;-) Feb 18, 2011 at 10:19
  • @Joachim: Haha okay. I just didn't feel like I could've added anything to the question by repeating the title, but thanks for the edit anyway. :)
    – user541686
    Feb 18, 2011 at 15:49
  • 1
    you could have added to the readability. In the title font it's hard to see which characters belong together and form an operator, for example. Feb 18, 2011 at 15:50

3 Answers 3

7

They are used for values that could be unordered, such as NaN for floats and doubles. 1 <>= NaN evaluates to false, whereas x <>= y evaluates to true for any pair of numbers, as long as neither number is NaN. The other operators you mention work the same, mutatis mutandis.

2
  • 2
    Link to documentation: digitalmars.com/d/2.0/…
    – stephan
    Feb 18, 2011 at 12:59
  • Thanks! :D @stephan: Thanks for the link! I thought I'd looked everywhere (the lexical page, the operator overloading page, etc.) but apparently I'd missed it.
    – user541686
    Feb 18, 2011 at 15:48
2

The long answer:

When dealing with floating point, two values will compare as one of A<B, A=B, A>B or unordered (if one is NaN).

The operators represent every interesting (non constant) row in the truth table. They can be interpreted as testing true for each of the cases for which the operator has the corresponding char, unless it has ! in which case the value is inverted.

1

They are comparison operators in D, just like ==, < and >=. In D the value nan (not a number) is taken into account. Two floating point numbers cannot only compare less, equal or greater, but also unordered, which is the case, if one of the comparands is nan.

Hence <>= means less, equal or greater. In other words <>= means ordered.

The comparison operators starting with an ! return exactly the opposite of their counterpart without the !. In particular, all of them evaluate to true, if one of the comparands is nan.

Here's a full list of all comparison operators in D:

  • ==
  • !=
  • >
  • >=
  • <
  • <=
  • !<>=
  • <>
  • <>=
  • !<=
  • !<
  • !>=
  • !>
  • !<>

You can find this list in the D documentation. The behaviours of all of these operators is explained there.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.