yurloc / iypt-planner

Helps organizers of IYPT tournament schedule juries
4 stars 0 forks source link

Evaluation of expression 1/(x-1) = 9223372036854775807 when x = 1 #55

Closed ota-svimbersky closed 8 years ago

ota-svimbersky commented 8 years ago

Hi, I've found an bug in dealing with an expression. I've made an following Java code:

Map<String, Object> params = new HashMap<>(); params.put("x", new Long(1); String value = MVEL.evalToString("1/(x-1)", params); // it is 1/(1-1) = 1/0 should be an Infinity or some Exception

It returns an 9223372036854775807 (the Long.maxValue) instead of Infinity/Exception.

If you change the expression to "(x-1)" the result is 0. If you type the formula "1/0" in/directly the result is Infinity.

Could you please fix this bug?

Thanks, Ota Svimbersky

Environment: JDK 1.8.0_60 (64bit) MVEL from maven

org.mvel mvel2 2.1.3.Final
yurloc commented 8 years ago

@ota-svimbersky Hi Ota, can you explain how this use case is related to IYPT Planner? Anyway, MVEL class is not part of this project. It resides in https://github.com/mikebrock/mvel/issues so it would be great if you could report the issue there. From you description it really looks like a bug that should be fixed.

ota-svimbersky commented 8 years ago

Sorry my mistake. I've accidentally wrote an issue to wrong browser window. Sorry.