diff --git a/framework-docs/modules/ROOT/pages/core/expressions/language-ref/operators.adoc b/framework-docs/modules/ROOT/pages/core/expressions/language-ref/operators.adoc index b533aa2bd56b..f658d77d4410 100644 --- a/framework-docs/modules/ROOT/pages/core/expressions/language-ref/operators.adoc +++ b/framework-docs/modules/ROOT/pages/core/expressions/language-ref/operators.adoc @@ -415,6 +415,8 @@ Java:: int maxInt = parser.parseExpression("(2^31) - 1").getValue(int.class); // Integer.MAX_VALUE + int minInt = parser.parseExpression("-2^31").getValue(int.class); // Integer.MIN_VALUE + // -- Operator precedence -- int minusTwentyOne = parser.parseExpression("1+2-3*8").getValue(int.class); // -21 @@ -479,6 +481,8 @@ Kotlin:: val maxInt = parser.parseExpression("(2^31) - 1").getValue(Int::class.java) // Integer.MAX_VALUE + val minInt = parser.parseExpression("-2^31").getValue(Int::class.java) // Integer.MIN_VALUE + // -- Operator precedence -- val minusTwentyOne = parser.parseExpression("1+2-3*8").getValue(Int::class.java) // -21 diff --git a/spring-expression/src/test/java/org/springframework/expression/spel/SpelDocumentationTests.java b/spring-expression/src/test/java/org/springframework/expression/spel/SpelDocumentationTests.java index aa6d6ec49749..5aedfcba8afc 100644 --- a/spring-expression/src/test/java/org/springframework/expression/spel/SpelDocumentationTests.java +++ b/spring-expression/src/test/java/org/springframework/expression/spel/SpelDocumentationTests.java @@ -429,6 +429,9 @@ void mathematicalOperators() { int maxInt = parser.parseExpression("(2^31) - 1").getValue(int.class); // Integer.MAX_VALUE assertThat(maxInt).isEqualTo(Integer.MAX_VALUE); + int minInt = parser.parseExpression("-2^31").getValue(int.class); // Integer.MIN_VALUE + assertThat(minInt).isEqualTo(Integer.MIN_VALUE); + // -- Operator precedence -- int minusTwentyOne = parser.parseExpression("1+2-3*8").getValue(int.class); // -21