- for Long values, the conversion from long to double can lead to loss of precision. Eg.

```
SELECT  CAST(ROUND(922337203685477580) AS LONG) as a
```

returns

```
922337203685477632
```

- for floating point values, when the two numbers passed to ROUND() funciton are too big, the values are truncated to Long.MAX_VALUE and hence wrongly rounded. Eg.

```
SELECT  ROUND(100000000000.0, 8) as a
```

returns

```
9.223372036854776E10
```
x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/expression/function/scalar/math/BinaryOptionalMathProcessor.java
public final void writeTo(StreamOutput out) throws IOException {
        out.writeNamedWriteable(left);
        out.writeOptionalNamedWriteable(right);
        out.writeEnum(operation);
    }
    @Override
    public Object process(Object input) {
        return doProcess(left().process(input), right() == null ? null : right().process(input));
    }
    public Number doProcess(Object left, Object right) {
        if (left == null) {
            return null;
        }
        if ((left instanceof Number) == false) {
            throw new SqlIllegalArgumentException("A number is required; received [{}]", left);
        }
        if (right != null) {
            if ((right instanceof Number) == false) {
                throw new SqlIllegalArgumentException("A number is required; received [{}]", right);
            }
            if (right instanceof Float || right instanceof Double) {
                throw new SqlIllegalArgumentException("An integer number is required; received [{}] as second parameter", right);
            }
        } else {
            right = 0;
        }
        return operation().apply((Number) left, (Number) right);
    }
    @Override
    public boolean equals(Object obj) {