BlinkenArea - GitList
Repositories
Blog
Wiki
mips_sys
Code
Commits
Branches
Tags
Search
Tree:
c2b0401
Branches
Tags
master
mips_sys
fw
format.c
added file headers
Stefan Schuermans
commited
c2b0401
at 2012-04-08 11:54:40
format.c
Blame
History
Raw
/* MIPS I system * Copyright 2011-2012 Stefan Schuermans <stefan@schuermans.info> * Copyleft GNU public license V2 or later * http://www.gnu.org/copyleft/gpl.html */ #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; } }