エントリーの編集
エントリーの編集は全ユーザーに共通の機能です。
必ずガイドラインを一読の上ご利用ください。
C++ float-to-int conversion can be undefined behavior
記事へのコメント0件
- 注目コメント
- 新着コメント
このエントリーにコメントしてみましょう。
注目コメント算出アルゴリズムの一部にLINEヤフー株式会社の「建設的コメント順位付けモデルAPI」を使用しています
- バナー広告なし
- ミュート機能あり
- ダークモード搭載
関連記事
C++ float-to-int conversion can be undefined behavior
Converting a float to an int in C++ is undefined behavior when the truncated float does not fit i... Converting a float to an int in C++ is undefined behavior when the truncated float does not fit into the destination integer. C++ makes it easy to do this accidentally. Much code gets this wrong. void foo(float f) { int i0 = f; int i1 = int(f); int i2 = static_cast<int>(f); } This code does not generate any warnings, not even with -Wall and -Wextra. -Wconversion only warns about the implicit conve

