Ask a Question
Ask Question Login
Corporate Training
  1. Community
  2. Salesforce
  3. Question
Salesforce

Explain apex division?

Asked by Clare Matthews Mar 3, 2023 1.1K views 3 answers
Share

About this question

Integer a = totalRecords.size(); //1250
decimal b = 400;
integer block = a/b;  //3
The actual result of 1250/400 is 3.125. Because I used an integer block, I got 3 as an answer. Instead of that if I use
decimal block = a/b;  

I get the result as 3.125

But what I want is, if the result is not perfect number (anything with decimals, like 3.125), I want it to be shown as 4 (increment by 1). If it's a perfect division, then I want to leave it as it is.

How to achieve this? Please let me know.

Another example:

1303/5 = 260.6, I want the result to be 261
1300/5 = 260.  I want 260 only.

Your answer

3 Answers

Dorothy Hall Latest answer

Answered on Nov 4, 2025

blocky blast puzzle delivers smooth performance across devices, giving mobile gamers a stable and lag-free experience even during fast gameplay sequences.

Was this helpful?

Andreeone23

Answered on Jan 6, 2025

I got it! Thanks for instruction me! 

Geoguessr

Was this helpful?

More Salesforce discussions

Learn & Explore

Free tutorials and interview questions from industry experts — learn the skill, then get ready to prove it.

Latest Salesforce Blogs

Guides, tips and career advice on Salesforce from JanBask experts.