- 496 名前:デフォルトの名無しさん mailto:sage [2009/10/28(水) 21:26:35 ]
- >>488
>double rohrer1 = 10000000*weight/(height*height*height); >double rohrer2 = weight/(height*height*height)*10000000; この書き方はintに丸められた(小数点以下切捨て)の結果を変数(double)に代入している。 >double rohrer1 = 10000000*(double)weight/(height*height*height); >double rohrer2 = (double)weight/(height*height*height)*10000000; 一方、この書き方は式にdoubleのデータ型が出現するために、すべての計算結果がdoubleになっている。 下の書き方のほうが高い精度(double)で計算されるのは当然。
|

|