Long Val1= 50000000000 ;

Throws an error Illegal Integer.How would i assign 50 billion value in salesforce ?


2 Answers 2


As a currency, you probably want decimal places, so:

Decimal val1 = 50000000000.0;

The .0 tells Apex that you want a Decimal value of arbitrary size and precision. This would be appropriate for most cases involving values destined to become part of a calculation involving currency or other fractional values.


Long variables are denoted with L in the end when assigned at compile time otherwise the number are treated as integers. You can also use Decimal if that works for you.

Long Val1= 50000000000L;
  • 1
    I would think if it's a currency value, Decimal is more appropriate than Long. Usually currencies undergo subsequent calculations and then the cents might matter.
    – Charles T
    Jan 24, 2021 at 15:55

Not the answer you're looking for? Browse other questions tagged .