How do you only display the last 5 digits of a number?
Example input:
123456789
Would return: 56789
Let's assume that required number to convert is an integer. Then you can use a modular mathematic - you can the number convert to the module with base 100 000. That means that only last 5 digits will be kept. The conversion can be done by an operator for remainder of division, the operator is %
.
The code is:
int x = 123456;
int lastDigits = x % 100000;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With