Daniel
Daniel

Reputation: 6842

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

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

example:

int time = CFAbsoluteGetCurrent();
int lastDigit;

Upvotes: 17

Views: 14038

Answers (1)

Georg Fritzsche
Georg Fritzsche

Reputation: 98984

Use modulo:

int lastDigit = time % 10;

Upvotes: 41

Related Questions