function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Sujendran Sundarraj 8Sujendran Sundarraj 8 

Annual revenue throws error : “Illegal Integer” with char 1000000000 and above

In my below code I am getting error as Illegal integer.
public void refedgeAnnualrevenue(list<Account> newAccts){
        for(Account ac : newAccts){
            if(ac.AnnualRevenue >= 0 && ac.AnnualRevenue <=49999999){
                ac.RefEdge_Annual_Revenue__c ='< $50M';
            } else if(ac.AnnualRevenue >= 50000000 && ac.AnnualRevenue <=499999999){
                ac.RefEdge_Annual_Revenue__c ='$50M-$500M';
            }else if(ac.AnnualRevenue >= 500000000 && ac.AnnualRevenue <=999999999){
                ac.RefEdge_Annual_Revenue__c ='$500M - $1B';
            }else if(ac.AnnualRevenue >= 1000000000  && ac.AnnualRevenue <=4999999999){
               ac.RefEdge_Annual_Revenue__c= '$1B - $5B';
            }else if(ac.AnnualRevenue >= 5000000000){
                ac.RefEdge_Annual_Revenue__c ='> $5B';
            }
        } 
    }


at the last two if else only.
Please help to fix this issue. Thank you.
AnudeepAnudeep (Salesforce Developers) 
Number fields are not of the Integer type in apex, but rather Double (or I believe Decimal in some cases), even if they are defined as not having any decimal places.

If you want to use a large constant value in apex you can either do as your latest example and make it a Long, use Double.valueOf('2147483648'); or any other way besides an integer literal.

There is no documentation that exists specifically since it's such a narrow use case, but the last sentence here confirms that Number fields are of a Decimal type.

Let me know if this helps, if it does, please mark this answer as best so that others facing the same issue will find this information useful. Thank you