Strict comparators

From semantic-mediawiki.org

In Semantic MediaWiki (SMW), comparators < and > have the meaning "smaller or equal" and "greater or equal". Thus they behave slightly different than some people would expect, because of their inclusion of "... or equal". Perhaps you'd like the comparators to behave like their mathematical counterparts. Since Semantic MediaWiki 1.5.3 this is possible, but with some caveats.

Enabling strict comparators[edit]

To enable strict interpretation of comparators add the following line to your "LocalSettings.php" file:

$smwStrictComparators = true;

Comparison between standard and strict comparators[edit]

For the different range comparisons, the following comparators are usable, depending on the setting of $smwStrictComparators:


Comparator
$smwStrictComparators
false
(default)
true
less than or equal <   or  
greater than or equal >   or  
less than << <   or   <<
greater than >> >   or   >>
Note that in SMW prior to 1.5.3 the behaviour of the comparators was a bit simpler
Comparator
less than or equal <
greater than or equal >
less than
greater than

Caveats with strict comparators[edit]

There are two points of attention when switching to strict comparators:

  1. existing queries using < and > may yield different results (this does not hold for < combined with !)
  2. the symbols ≤ and ≥ cannot easily be inserted in a wiki with a standard keyboard. Users may need to
    1. copy & paste the symbols, or
    2. use additional software, like Windows' "Character Map" (Start > Programs > Accessories > System Tools > Character Map, then to font "Symbol"), or
    3. in US Windows English keyboard, you can do "Alt+242" to input ≥ and "Alt+243" for ≤.