さて…またC++の勉強でもしますか。
C++における数値型int 整数型 short 短整数型 long 長整数型
float 実数型 double 倍精度実数型
long double ロング倍精度実数型
現在やってるのは「整数型」と「実数型」。
割り算に注目。
#include
main(){
int a=7, i=3;
float f=3;
main(){
int a=7, i=3;
float f=3;
cout << "7/3="<< a/i << endl;
cout << "7/3.0=" << a/f << endl;
}出力結果 7/3=2
7/3.0=2.33333
実数型と整数型で違いが生じる。
小数点以下の切捨ての有無。
また整数型専用の演算子 % (余り)がある。
トラックバックURL
→http://jigenrange.blog95.fc2.com/tb.php/75-a4b3cfe2
この記事にトラックバックする(FC2ブログユーザー)