0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

printf()の指数表示で指数部が3桁になる

Posted at

Windows で C のプログラムを書いている際、printf()の浮動小数点数の出力において指数表示を指定すると、指数部が3桁で表示されることがあるのですが、これは導入した C コンパイラが古い MSVC のライブラリをリンクすると起きるようです。

#ifdef _TWO_DIGIT_EXPONENT
unsigned int oldexpform = _set_output_format(_TWO_DIGIT_EXPONENT);
#endif 

などとmain()冒頭あたりに書いておけば多分解決。

本当は何故そのようなリンクが起きるのかを書くべきなんですが、ちょっとそこまで追究せずに環境を作り直しちゃったので、すいませんがメモ止まりということで。

参考:https://learn.microsoft.com/ja-jp/cpp/c-runtime-library/set-output-format?view=msvc-170

0
0
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?