Compare() public static method

public static Compare ( PhpNumber x, PhpValue y ) : int
x PhpNumber
y PhpValue
return int
Example #1
0
        /// <summary>
        /// Compares two objects in a manner of PHP numeric comparison.
        /// </summary>
        public int Compare(PhpValue x, PhpValue y)
        {
            PhpNumber numx, numy;

            var info_x = x.ToNumber(out numx);
            var info_y = y.ToNumber(out numy);

            // at least one operand has been converted to double:
            if (((info_x | info_y) & Convert.NumberInfo.Double) != 0)
            {
                return(Comparison.Compare(numx.ToDouble(), numy.ToDouble()));
            }

            // compare integers:
            return(Comparison.Compare(numx.ToLong(), numy.ToLong()));
        }
Example #2
0
 public static bool operator !=(PhpValue left, string right) => Comparison.Compare(right, left) != 0;
Example #3
0
 /// <summary>
 /// Non strict inequality operator.
 /// </summary>
 public static bool operator !=(PhpNumber a, PhpValue b) => Comparison.Compare(a, b) != 0;
Example #4
0
 public override int Compare(ref PhpValue me, PhpValue right) => Comparison.Compare(me.WritableString.ToString(), right);
Example #5
0
 public override int Compare(ref PhpValue me, PhpValue right) => Comparison.Compare(me.String, right);
Example #6
0
 public override int Compare(ref PhpValue me, PhpValue right) => Comparison.Compare(me.Boolean, right);
 public override int Compare(ref PhpValue me, PhpValue right) => Comparison.Compare(me.Object, right);
Example #8
0
 /// <summary>
 /// Compares two objects in a manner of PHP numeric comparison.
 /// </summary>
 public int Compare(PhpValue x, PhpValue y)
 {
     return(Comparison.Compare(_compare.Invoke(_ctx, x, y).ToDouble(), 0.0));
 }