X
Xavier Roche
Hi folks,
Are there any rules regarding cast result from double to
int64_t/uint64_t for positive/negative infinity, or is the result
totally undefined ?
Typically, playing with cast on x86-64 arch (Linux/gcc) leads to the
following observations:
(uint64_t) -inf == 9223372036854775808 (8000000000000000)
(uint64_t) inf == 0 (0)
(int64_t) -inf == -9223372036854775808 (8000000000000000)
(int64_t) inf == -9223372036854775808 (8000000000000000)
(I was expecting (uint64_t) inf to give 0xffffffffffffffff for example)
[ I could play with finite()/isinf(), but I was wondering if a fast
method would be available/documented. ]
Are there any rules regarding cast result from double to
int64_t/uint64_t for positive/negative infinity, or is the result
totally undefined ?
Typically, playing with cast on x86-64 arch (Linux/gcc) leads to the
following observations:
(uint64_t) -inf == 9223372036854775808 (8000000000000000)
(uint64_t) inf == 0 (0)
(int64_t) -inf == -9223372036854775808 (8000000000000000)
(int64_t) inf == -9223372036854775808 (8000000000000000)
(I was expecting (uint64_t) inf to give 0xffffffffffffffff for example)
[ I could play with finite()/isinf(), but I was wondering if a fast
method would be available/documented. ]