Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

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

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

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

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report