1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
|
char* append_chars(char* dest, const char* src)
{
char* rdest = dest;
while (*dest)
dest++;
while (*dest++ = *src++)
;
return rdest;
}
static inline const char* tocnstch(int num_)
{
const char* int_cnst_chars[10] =
{
"0",
"1",
"2",
"3",
"4",
"5",
"6",
"7",
"8",
"9",
};
char cnst_ch[20] = "";
int temp_i = num_;
int temp_ch = 0;
for (int i = get_quantity_of_digits(num_, false); i > 0; i--)
{
int ch_i = 0;
if (i == get_quantity_of_digits(num_, false))
{
ch_i = int(floor(num_ / pow(10, i - 1)));
temp_ch = ch_i;
}
//5914 -- 91
else
{
float f = temp_i - (temp_ch * pow(10, (get_quantity_of_digits(num_, false) - (get_quantity_of_digits(num_, false) - i))));
float g = pow(10, get_quantity_of_digits(f, false) - 1);
ch_i = int(floor(f / g));
temp_i = f;
temp_ch = ch_i;
}
append_chars(cnst_ch, int_cnst_chars[ch_i]);
}
return (const char*)cnst_ch;
}
| |