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

An example Analysis of floating-point number format Control of Clipper 11

2025-01-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

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

This article mainly introduces the "example analysis of floating-point format control of Clear11 floating-point number". In daily operation, I believe that many people have doubts about the analysis of floating-point format control of Crank11. The editor has consulted all kinds of data and sorted out simple and easy-to-use operation methods. I hope it will be helpful for you to answer the doubts of "example analysis of floating-point format control of Category 11". Next, please follow the editor to study!

Operators in iostream

I believe every C++ programmer has seen the following code.

As far as the author is concerned, it has been known for a long time that endl is a newline character, similar to "\ n". Another realization is that cout can only automatically determine the content of the output, so it will be used back to printf when you need to change the output format, which is a bit awkward, but it doesn't dig into it.

I didn't know that endl is an manipulator until I wrote this official account article. In addition to endl, many operators are provided in the IO library that can be used to control the format of the output. The details are as follows.

This picture is from the fifth edition of C++Primer

Operator example

Controls the binary representation of integer output

The code uses showbase/noshowbase to turn on and off the binary representation, and oct/hex/dec to control the base of the output. The output is as follows:

Control floating point format

The output format of floating-point numbers can also be controlled, and the following code is an example of controlling the output precision.

The code output is as follows:

What's New in Clipper 11

Two new operators, hexfloat and defaultfloat, have been introduced in Clippers 11. Used to specify the floating point output format as hexadecimal and decimal, respectively.

The code output is as follows:

At this point, the study of "example Analysis of floating-point format Control in Clear11" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

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

Internet Technology

Wechat

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

12
Report