-->

C/Objective-C read and get last digit of integer?

2019-02-16 07:17发布

问题:

How can i get the last digit of an integer (or NSInteger) outputted to integer?

example:

int time = CFAbsoluteGetCurrent();
int lastDigit;

回答1:

Use modulo:

int lastDigit = time % 10;