Get the App
SLTechnology News&Howtos  ›  Development  › 

How to output long decimal numbers in binary and hexadecimal form without using printf series library functions

Shulou Source: shulou.com Published: 2022-06-03 05:50:22 11月17日 Update

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

Tags: Output hexadecimal binary function decimal form decimal content skill knowledge binary concise concise but just article time more format article Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno OPPO Reno macOS Docker vpn MariaDB