/// <summary> /// Compares two Nodes for Numeric Ordering /// </summary> /// <param name="x">Node</param> /// <param name="y">Node</param> /// <param name="type">Numeric Type</param> /// <returns></returns> protected int NumericCompare(INode x, INode y, SparqlNumericType type) { if (x == null || y == null) { throw new RdfQueryException("Cannot evaluate numeric ordering when one or both arguments are Null"); } if (type == SparqlNumericType.NaN) { throw new RdfQueryException("Cannot evaluate numeric ordering when the Numeric Type is NaN"); } ILiteralNode a = (ILiteralNode)x; ILiteralNode b = (ILiteralNode)y; switch (type) { case SparqlNumericType.Decimal: return(SparqlSpecsHelper.ToDecimal(a).CompareTo(SparqlSpecsHelper.ToDecimal(b))); case SparqlNumericType.Double: return(SparqlSpecsHelper.ToDouble(a).CompareTo(SparqlSpecsHelper.ToDouble(b))); case SparqlNumericType.Float: return(SparqlSpecsHelper.ToFloat(a).CompareTo(SparqlSpecsHelper.ToFloat(b))); case SparqlNumericType.Integer: return(SparqlSpecsHelper.ToInteger(a).CompareTo(SparqlSpecsHelper.ToInteger(b))); default: throw new RdfQueryException("Cannot evaluate numeric equality since of the arguments is not numeric"); } }