Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What do these operators do in D 2.0: <>= !<>= !<= !>=

Tags:

d

What do these operators do in D 2.0:

  • <>=
  • !<>=
  • !<=
  • !>=
like image 787
user541686 Avatar asked Feb 18 '11 10:02

user541686


2 Answers

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.

like image 125
Marcelo Cantos Avatar answered Oct 13 '22 22:10

Marcelo Cantos


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.

like image 22
BCS Avatar answered Oct 13 '22 21:10

BCS