Salesforce Fact #784 | Min Integer value in apex

How to use the min Integer value in apex?

Suppose we need to use the minimum Integer value in apex. Now, the minimum value is -2147483648. We get an error if we try to directly assign it to a variable. So, here's the workaround:

Integer i = -2147483648;  // Illegal integer

Integer i = -2147483647-1; //this works

Reference: One of the problems on https://www.apexsandbox.io/

Comments

Popular posts from this blog

Salesforce Fact #192 | Call batch apex from flow

Salesforce Fact #457 | Get current user role name in flow