こんにちは。松林です。
たくさんの方から,レスいただきありがとうございました。
とても勉強になりました。
#include <stdio.h>
void main()
{
unsigned x;
double a,b,c,d;
x=10;
a= -x*-x;
b= -x*x;
c= x*x;
d= -1*x*x;
printf("%lf, %lf, %lf, %lf\n",a,b,c,d);
}
/*
100.000000, 4294967196.000000, 100.000000, 4294967196.000000
*/
TANAKA Yoshitomo wrote at Tue, 26 Feb 2002 18:11:45 +0900 as follows.
>式の返す型は、式中に現れる型の中でもっとも格の高いものになります
>ANSIの規格では
>int < unsigned int < long < unsigned long < float < double
>の順です。つまり unsiged x; であるから
> -x
>の型はunsigedであり、
> -1.0 * x
>の型はdoubleです。
// Katsushi MATSUBAYASHI matsu@xxxxxxxxxxxxxx
// Associate Professor, Tokyo National College of Technology