diff --git a/core/src/main/java/com/schibsted/spt/data/jslt/impl/NodeUtils.java b/core/src/main/java/com/schibsted/spt/data/jslt/impl/NodeUtils.java index e3b71496..00721179 100644 --- a/core/src/main/java/com/schibsted/spt/data/jslt/impl/NodeUtils.java +++ b/core/src/main/java/com/schibsted/spt/data/jslt/impl/NodeUtils.java @@ -182,6 +182,10 @@ else if (number.length() < 19) long decimalPart = Long.parseLong(number.substring(endInteger + 1, endDecimal)); int digits = endDecimal - endInteger - 1; + // if intPart is negative we can't add a positive decimalPart to it + if (intPart < 0) + decimalPart = decimalPart * -1; + value = (decimalPart / Math.pow(10, digits)) + intPart; pos = endDecimal; diff --git a/core/src/test/resources/function-tests.json b/core/src/test/resources/function-tests.json index 33d43d3a..2725cc07 100644 --- a/core/src/test/resources/function-tests.json +++ b/core/src/test/resources/function-tests.json @@ -782,6 +782,16 @@ "input" : "{}", "output" : "124274772478237237823782728372873000000012347427427378238238283" }, + { + "query" : "number(\"-1.4\")", + "input" : "{}", + "output" : "-1.4" + }, + { + "query" : "number(\"-2.513\")", + "input" : "{}", + "output" : "-2.513" + }, { "input" : "{}", "output" : "2",