How to output long decimal numbers in binary and hexadecimal form without using printf series library functions
This article shows you how to output long decimal numbers in binary and hexadecimal form without using printf series library functions, the content is concise and easy to understand, and can definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.
/ / hexadecimal output
Char* test3 (long num) {
Char* buffer = char*) malloc (11)
Buffer [0] ='0'
Buffer [1] ='x'
Buffer [10] ='/ 0'
Char* temp = buffer + 2
For (int item0; I
< 8; i++) { temp[i] = (char)(num28); temp[i] = temp[i] >= 0? Temp [I]: temp [I] + 16
Temp [I] = temp [I]
< 10 ? temp[i] + 48 : temp[i] + 55; } return buffer; } //R进制的输出 void print(int n) { stack k; for(;(n+R-1)/R;) { k.push(n%R); n=n>> 1
}
For (;! k.empty ())
{
Cout