Skip to content

Commit

Permalink
Provide example for calculating Integer.MIN_VALUE with SpEL's power o…
Browse files Browse the repository at this point in the history
…perator
  • Loading branch information
sbrannen committed Feb 2, 2024
1 parent 1e432ff commit 7025b7a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 7025b7a

Please sign in to comment.