내가 int
인 경우 double
으로 변환 한 다음 double
을 int
으로 다시 변환하면 시작한 것과 동일한 값을 다시 얻을 수 있습니까?int-> double-> int는 값 보존을 보장합니까?
int passThroughDouble(int input)
{
double d = input;
return d;
}
오전 내가 passThroughDouble(x) == x
모든 int
의 x
보장 : 즉,이 기능을 부여?
int 크기에 따라 달라집니다. 64 비트 ints이 확실히 작동하지 않습니다. 32 비트 정수의 경우 아마 * 작동합니다. –
'assert (std :: numeric_limits :: digits <= std :: numeric_limits :: digits); - http://en.cppreference.com/w/cpp/types/numeric_limits/digits –
sehe
@sehe : 확실하게 'static_assert'를 의미합니다. : P – GManNickG