In most languages that use it, it represents the modulus operation.

In APEX, you use Math.Mod()

if (Math.Mod(x, 2) == 0) {
    system.debug(x + ' is even');
}

APEX Expression Operators Reference shows that there is no definition of a % operator.

Answer from gNerb on Stack Exchange
🌐
YouTube
youtube.com › watch
Math Class Methods - Apex Programming Level 5 ⭐⭐⭐⭐⭐ - YouTube
This video explains different methods of Math class in Apex.Please subscribe if you haven't subscribed to us yet - https://bit.ly/3v61lv5--------------------...
Published   November 7, 2022
🌐
Infallibletechie
infallibletechie.com › 2012 › 11 › mathematical-functions-using-apex-in.html
Mathematical functions using apex in Salesforce – InfallibleTechie
Integer result; //Finding minimum value result = math.min(a,b); //Finding maximum value result = math.max(a,b); //Modulo division result = math.mod(a,b); · http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_methods_system_math.htm
🌐
Pablo Gonzalez
pablogonzalez.io › apex-methods-should-do-one-thing-but-what-is-one-thing
Efficient Apex: methods should do one thing, but what is one thing?
July 10, 2024 - public class Password { public ... = Math.mod(Math.abs(Crypto.getRandomInteger()), chars.length()); password += chars.substring(idx, idx+1); } return password; } } ... The Site class has some methods for reseting password. This use case is simply an illustration and not an encouragement to re-create existing logic from the Apex ...
🌐
Wordpress
salesforceforfresher.wordpress.com › 2021 › 06 › 13 › mathematical-programs-salesforce-apex-trigger
Mathematical Programs Salesforce Apex Trigger – Salesforce For Freshers
July 9, 2021 - Firstly we have to create an object of name “ MPC__c“. This apex trigger takes two fields 1. Mode_Output__c, 2. Values_to_calculate_mode__c. In statistics maths, a mode is a value that occurs the highest numbers of time. For Example − ...
🌐
Iqra Technology
iqratechnology.com › academy › salesforce-apex-training › math-class-in-apex
Math Class in Apex – Iqra Technology
July 29, 2025 - 1. Static Utility Class: All methods in the Math class are static, which means you can call them directly using Math. prefi 2. Common Mathematical Operations: Includes rounding, absolute values, power calculations, square roots, etc.
Find elsewhere
🌐
Salesforce Developers
developer.salesforce.com › forums
modulus operator in apex classes
On December 4, 2023, Salesforce Developers discussion forums joined the Trailblazer Community. Learn more with our FAQs!
🌐
Blogger
salesforcetechsolution.blogspot.com
Salesforce and Apex
This also allows you to // get strings in the form of "forty-five hundred" if called directly. public static String convert_nnn(integer val) { String word = ''; integer rem = val / 100; integer mod = Math.mod(val,100); if (rem > 0) { word = to_19[rem] + ' hundred'; if (mod > 0) { word += ' '; } } if (mod > 0) { word += convert_nn(mod); } return word; } public static String english_number(long val) { if (val < 100) { return convert_nn(val.intValue()); } if (val < 1000) { return convert_nnn(val.intValue()); } for (integer v = 0; v < denom.size(); v++) { integer didx = v - 1; integer dval = (inte
🌐
Apex Hours
apexhours.com › home › salesforce developer › what is apex? a complete guide
What is Apex? A Complete Guide - Apex Hours
Introduction to Apex Part 1 : Assignment completed ... Integer sum=0; for (Integer i =1; i<=20; i++) { mylist.add(i); //system.debug(mylist); } Integer j = 0; while(j < 20 ) { integer check=math.mod(j, 2); if(check == 0) { sum = sum + mylist[j]; } j++; } System.debug('Sum is ' +sum);
Published   June 10, 2024
🌐
Salesforce Blog
sfdcpoint.com › home › apex random number salesforce
apex random number Salesforce - Salesforce Blog
November 20, 2018 - Integer randomNumber = Integer.valueof((math.random() * 10)); Boolean randomBoolean = Math.mod(randomNumber,2) == 0 ? true : false; System.debug('randomBoolean is'+randomBoolean); List<String> availableValues = new List<String>{'Red','Green','Blue','White','Black'}; Integer listSize = availableValues.size() - 1; Integer randomNumber = Integer.valueof((Math.random() * listSize)); String randomString= availableValues[randomNumber]; System.debug('randomString is'+randomString); Apex, salesforce ·
🌐
Salesforcefaqs
salesforcefaqs.com › mod-function-in-salesforce
MOD() Function in Salesforce | Syntax, Examples, & Use Cases
October 10, 2025 - The MOD() function in Salesforce is a mathematical function used to perform calculations.
🌐
Salesforce Thinkers
salesforcethinkers.home.blog › 2020 › 04 › 14 › math-formula-operators-and-functions-in-salesforce
Math Formula Operators and Functions in Salesforce – Salesforce Thinkers
April 14, 2020 - HELLO Salesforce Thinkers, In our previous blog we learned about Logical Formula Functions in Salesforce, In this blog we are going to learn about “Math Formula Operators and Functions in Salesforce”. Math Formula Operators: We have the following Math Operators in Salesforce.
🌐
Apexsandbox
apexsandbox.io › problem › 5
Apex Practice Problems - ApexSandbox.io
Become an expert Apex developer with a growing collection of Apex programming problems
🌐
Reddit
reddit.com › r/salesforce › mod() function help
r/salesforce on Reddit: MOD() function help
July 10, 2016 - For example, I understand the smaller examples the help text uses MOD(123, 100) = 23 because 123/100 = 1.23 with 23 being the remainder. But what about larger numbers like the example suggests using dates? I tried to understand the example they used by replacing the generic "My_Date__c" with a specific date.
🌐
salesforce-solutions
subhashrdssv.wixsite.com › salesforce-solutions › single-post › 2016-1-23-converting-a-number-to-text-using-apex-trigger-and-apex-class
Converting a Number to Text using Apex Trigger and Apex Class
January 23, 2016 - '' + convert(math.mod(i , 10)):''); if( i < 1000) return units[integer.valueOf(i)/100] + ' Hundred and' + ((math.mod(i , 100) > 0)?' ' + convert(math.mod(i , 100)):''); if( i < 10000) return units[integer.valueOf(i)/1000] + ' Thousand ' + ((math.mod(i , 1000) > 0)?' ' + convert(math.mod(i , 1000)):''); if( i < 100000) return convert(i / 1000) + ' Thousand ' + ((math.mod(i , 1000) > 0)?