5000UL mean 5000 but the UL tells the compiler to treat it as a unsigned long (UL). Because the compiler uses the biggest variable type in the calculation to do the calculation including all intermediate steps. For example, if you would do
unsigned int valA = 1000;
volatile unsigned int div = 500;
unsigned int outcomeA = valA * 5000 / div; //will become 38
unsigned int outcomeB = valA * 5000UL / div; //will become 10000 as expected
The intermediate outcome 5000000 does NOT fit a unsigned int and is cropped. Bu forcing it a unsigned long the math is correct again ![]()