...und in C++ (jeweils 1 Zeile Eingabe und 1 Zeile Ausgabe):
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
double x = 3.9
(double) 3.9000000
sizeof(x)
(unsigned long) 8
x & 0xFF
error: invalid operands to binary expression ('double' and 'int')
x & 0xFF
~ ^ ~~~~
static_cast<uint64_t>(x) & 0xFF
(unsigned long) 3
*reinterpret_cast<uint64_t*>(&x)
(unsigned long) 4615964438073389875
*reinterpret_cast<uint64_t*>(&x) & 0xFF
(unsigned long) 51
Last edited: 2024-05-07 09:54:42 +0200 (CEST)