cast_operatorプロジェクト

「cast_operatorプロジェクト」の編集履歴(バックアップ)一覧はこちら

cast_operatorプロジェクト」(2010/07/08 (木) 13:07:37) の最新版変更点

追加された行は緑色になります。

削除された行は赤色になります。

***cast_operator.c #highlight(c){{ /*------------------------------------------------------------------------------ * Title: cast_operator * Project: cast_operator * Source: cast_operator.c * Author: B.G * Group: B.G * Created: 13:30 2009/11/07 * Last Modified: 13:30 2009/11/07 * ---------------------------------------------------------------------------*/ /* ヘッダファイルのインクルード */ #include <stdio.h> /* stdio.hのインクルード */ /* main関数 */ int main(void){ /* 変数の宣言 */ float result_normal; /* キャスト演算子を使わずに計算した結果を格納するfloat変数result_normal */ float result_cast; /* キャスト演算子を使って計算した結果を格納するfloat変数result_cast */ /* キャスト演算子を使わずに計算 */ result_normal = 2 / 5 + 3.2; /* 2 / 5は整数で計算されるので0となり、それに3.2を足すので、result_normal = 3.2 */ printf("2 / 5 + 3.2 = %f\n", result_normal); /* 結果をprintfで出力 */ /* キャスト演算子を使って計算 */ result_cast = (float)2 / (float)5 + 3.2; /* 2 / 5は実数で計算されるので0.4となり、それに3.2を足すので、result_normal = 3.6 */ printf("(float)2 / (float)5 + 3.2 = %f\n", result_cast); /* 結果をprintfで出力 */ /* プログラムの終了 */ return 0; } }}

表示オプション

横に並べて表示:
変化行の前後のみ表示: