当前位置:网站首页>Keep valid digits; Keep n digits after the decimal point;
Keep valid digits; Keep n digits after the decimal point;
2022-06-27 15:29:00 【Yang Yi】
Catalog
After decimal point n position
Keep valid numbers
(1)setprecision(n)
- The header file #include<iomanip>
- Specify the total number of display digits for a floating-point number , among n Is the number of digits required ( The sum of the digits before and after the decimal point .), namely Retain n Significant digits ;
- rounding Make a reservation ;
- Not enough significant digits , Can't Make up automatically 0 ( If you want to make up 0 You can add showpoint namely cout<<setprecision(n)<<showpoint<<a; )
- Until the accuracy changes , always Keep the effect
- If the number of digits before the decimal point More than Number of digits to be reserved , Use scientific counting


(2)%g
- Keep valid numbers ; %.6g For the sake of reservation 6 Significant digits .
- If there is a suffix in the decimal part 0, be No output suffix 0;
- The default precision is 6; %g Default hold 6 Significant digits


After decimal point n position
(1)fixed
- You can force numbers to appear in the form of unscientific counting , By default , It can repair the decimal point 6 position ,
- fixed<<setprecision(n) The combination can be kept after the decimal point n position , Can be supplemented automatically 0

(2)%f %lf
- %.2f float The type is reserved after the decimal point 2 position , %.2lf double The type is reserved after the decimal point 2 position
- Not enough digits , It can mend 0

Be careful : Integer operation , If the last output result is decimal , To convert an integer to a floating point number
边栏推荐
- sql注入原理
- Design and implementation of reading app based on Web Platform
- Redis CacheClient
- Pycharm安装与设置
- [xman2018 qualifying] pass
- Pisa-Proxy 之 SQL 解析实践
- Programming skills: script scheduling
- ThreadLocal之强、弱、软、虚引用
- 关于TensorFlow使用GPU加速
- Go error collection | when a function uses a return value with a parameter name
猜你喜欢

E ModuleNotFoundError: No module named ‘psycopg2‘(已解决)

CAS comparison and exchange

What is the London Silver code

原子操作类

Using redis skillfully to realize the like function, isn't it more fragrant than MySQL?
![[digital signal processing] discrete time signal (analog signal, discrete time signal, digital signal | sampling leads to time discrete | quantization leads to amplitude discrete)](/img/80/28d53985d56d64ca721b26e846c667.jpg)
[digital signal processing] discrete time signal (analog signal, discrete time signal, digital signal | sampling leads to time discrete | quantization leads to amplitude discrete)

Atomic operation class

Reflection learning summary

volatile与JMM

All you want to know about large screen visualization is here
随机推荐
基于Vue+Node+MySQL的美食菜谱食材网站设计与实现
SQL parsing practice of Pisa proxy
E-week finance Q1 mobile banking has 650million active users; Layout of financial subsidiaries in emerging fields
Massive data! Second level analysis! Flink+doris build a real-time data warehouse scheme
my. INI file configuration
手机号码的格式
volatile与JMM
Buuctf Misc
洛谷入门1【顺序结构】题单题解
Excuse me, is it cost-effective to insure sunshine Optimus Prime term life insurance No. 7? What are the advantages of this product?
2022-06-27日报:Swin Transformer、ViT作者等共话:好的基础模型是CV研究者的朴素追求
What kind of experience is it to read other people's code
设计原则和思想:设计原则
CentOS8-postgresql初始化时报错:initdb: error: invalid locale settings; check LANG and LC_* environment
AQS Abstract queue synchronizer
2022-2-16 learning the imitated Niuke project - Section 6 adding comments
CAS之比较并交换
Fundamentals of software engineering (I)
洛谷_P1002 [NOIP2002 普及组] 过河卒_dp
Vscode uses yapf auto format to set the maximum number of characters per line