#include <stdio.h>
int main()
{
int a,b;
float r1;
a=100;
b=99;
r1=a/b;
printf("%f", r1);
}
저렇게해서 하면 1.000000으로 되서 왜 정수로 나오죠 r1은 float이라고 했는데
근데 int a,b 저기서 int를 float로 나오니까 1.010101으로 정상으로 나오는데..
#include <stdio.h>
int main()
{
int a,b;
float r1;
a=100;
b=99;
r1=a/b;
printf("%f", r1);
}
저렇게해서 하면 1.000000으로 되서 왜 정수로 나오죠 r1은 float이라고 했는데
근데 int a,b 저기서 int를 float로 나오니까 1.010101으로 정상으로 나오는데..
http://ezdispatch.tistory.com/48
형변환에 대해서 공부해 보아요
a/b자체는 int끼리 연산하는거니까 실수는 다 짤리지. 그걸 플로트에 대입해봤자 실수는 이미 다 날아간상태잖아 ㅋㅋㅋ
으