BlinkenArea - GitList
Repositories
Blog
Wiki
mips_sys
Code
Commits
Branches
Tags
Search
Tree:
6360daf
Branches
Tags
master
mips_sys
fw
format.c
added debug output functions
Stefan Schuermans
commited
6360daf
at 2012-04-05 21:31:40
format.c
Blame
History
Raw
#include "format.h" /** * @brief convert unsigned integer to decimal * @param[in] uint unsigned integer value * @param[in] cnt number of digits * @param[out] digits value as decimal digits */ void format_uint2dec(unsigned int uint, unsigned int cnt, char digits[]) { while (cnt > 0) { --cnt; digits[cnt] = '0' + uint % 10; uint /= 10; } } /** * @brief convert unsigned integer to hexadecimal * @param[in] uint unsigned integer value * @param[in] cnt number of digits * @param[out] digits value as decimal hexadigits */ void format_uint2hex(unsigned int uint, unsigned int cnt, char digits[]) { unsigned int val; while (cnt > 0) { --cnt; val = uint & 15; digits[cnt] = val < 10 ? '0' + val : 'A' - 10 + val; uint >>= 4; } }