MCPcopy Create free account
hub / github.com/BaseXdb/basex / parse

Method parse

basex-core/src/main/java/org/basex/query/value/item/Dbl.java:146–155  ·  view source on GitHub ↗

Converts the given token into a double value. @param value value to be converted @param info input info (can be null) @return double value @throws QueryException query exception

(final byte[] value, final InputInfo info)

Source from the content-addressed store, hash-verified

144 * @throws QueryException query exception
145 */
146 public static double parse(final byte[] value, final InputInfo info) throws QueryException {
147 final double d = Token.toDouble(value);
148 if(!Double.isNaN(d)) return d;
149
150 final byte[] v = Token.trim(value);
151 if(Token.eq(v, Token.NAN)) return Double.NaN;
152 if(Token.eq(v, Token.POSITIVE_INF, Token.POSITIVE_INF_PLUS)) return Double.POSITIVE_INFINITY;
153 if(Token.eq(v, Token.NEGATIVE_INF)) return Double.NEGATIVE_INFINITY;
154 throw BasicType.DOUBLE.castError(value, info);
155 }
156
157 /**
158 * Returns a JSON-compliant string representation of a double value.

Callers 8

numberLitMethod · 0.95
numericLiteralMethod · 0.95
getMethod · 0.95
readMethod · 0.95
compareMethod · 0.95
dblMethod · 0.95
readMethod · 0.95
dblMethod · 0.95

Calls 5

toDoubleMethod · 0.95
trimMethod · 0.95
eqMethod · 0.95
isNaNMethod · 0.80
castErrorMethod · 0.80

Tested by

no test coverage detected