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
kito kidkito kid 

integer divisions always get 0

Integer a = 123;

Integer b = 300;

Dobule result = 0.0;

result = (a/b) * 100;

 

For that above method, whenever I make division always getting 0.

Any idea?

Satish_SFDCSatish_SFDC
Hi,
Because a and b variables are integers, the division truncates the decimal part of the result. You can make atleast one of the variables as Double and the result will be a double.

Regards,
Satish Kumar
Please mark my answer as a solution if it was helpful so it is available to others as a proper solution.
If you felt I went above and beyond, please give me Kudos by clicking on the star icon.