Skip to content

Instantly share code, notes, and snippets.

@yorkie
Last active August 29, 2015 13:57
Show Gist options
  • Select an option

  • Save yorkie/9543953 to your computer and use it in GitHub Desktop.

Select an option

Save yorkie/9543953 to your computer and use it in GitHub Desktop.
get the digit of a integer number
#include <cmath>
/*
* get the digit of a integer number
*/
static int
get_digit(int num) {
if (num == 0)
return 0;
else
return (int)log10((int)num)+1;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment