기본 콘텐츠로 건너뛰기

[C/C++] int형, float형 나눗셈/나머지 구하기 연산 결과

// divmod_test.cpp : int형, float형 div/mod 연산 테스트
//

#include "stdafx.h"

void test_divmod()
{
int nzero = 0;
//int nd = 20 / nzero; // VS2010 runtime error
//int nm = 20 % nzero; // VS2010 runtime error

float fzero = 0.f;
float fk = 20.f / fzero; // VS2010 no error!!! - fk = '1.#INF000'
//float fj = 20 % fzero; // VS2010 compile error - float type not support modulation operation.
printf("fk(%f)", fk);
}

int _tmain(int argc, _TCHAR* argv[])
{
test_divmod();
return 0;
}

댓글