Skip to content

Negative integer literals (w/unary minus sign) incorrectly interpreted as floats #5465

Description

@jquartel

If you have an integer-only expression you expect the result to remain integer, but here are a couple of instances where using a negative integer can result in a floating point result (note that the only way I know how to test for the resultant type is to use toString):

  1. If the first (or only) value of the expression is a negative integer, as in
    toString(-1+2,"%d")

  2. If a variable in a with() or forEach() function is a negative integer, as in
    with(-1,a,toString(2+a,"%d"))

In both of these cases the result is
Error: java.util.IllegalFormatConversionException: d != java.lang.Double
but if you use "%f" in the string conversion you get 1.000000 .

I am using OpenRefine Version 3.6.2 in Safari Version 16.1 on MacOS 12.6.1 .

Metadata

Metadata

Assignees

Labels

Type: BugIssues related to software defects or unexpected behavior, which require resolution.grelThe default expression language, GREL, could be improved in many ways!

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions