本文介绍了什么是setprecision(12)和setprecision(012)之间的区别的原因,例如,在c ++?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在c ++中,当你写setprecision(12)例如,12是在10的底部,但当你写它像setprecision(012)它是一个八进制数,为什么?

C ++草稿标准()§2.13.1



它与setprecision没有任何关系。


In c++ when you write setprecision (12) for example, 12 is in the base of 10 but when you write it like setprecision (012) it is an octal number,why?

解决方案

Because constants with leading zeros (other than leading 0x) are always octal:

C++ draft standard (n1905) §2.13.1

It has nothing at all to do with setprecision.

这篇关于什么是setprecision(12)和setprecision(012)之间的区别的原因,例如,在c ++?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-03 14:54