/// @note: char for size only, debatable, will wind up as an int anyway. return type was also char but is long due to the assignment requirements uint dgti(ullong num, uint pos) { // std::stringstream ss; ss << num; // size_t len = std::string(ss.str()).length(); // TODO use int_length now instead size_t len = int_length(num); ullong right_cut = num / (llong) pow(10, len - pos); // NOTE len-pos >= 0 return (uint) right_cut % 10; }
/** * print the bits of a number * @params number - the number we want to print his bits * @returns void - print the number of bits (doesn't return anything) */ void print_bit(unsigned int number) { int i = 0; while (i < int_length()) { printf("%d", get_last_bit(number)); number >>= 1; i++; } printf("\n"); }