Thread Integer-Maske (5 answers)
Opened by rosti at 2024-05-06 17:29

Raubtier
 2024-05-07 09:51
#196121 #196121
User since
2012-05-04
1075 Artikel
BenutzerIn
[default_avatar]
...und in C++ (jeweils 1 Zeile Eingabe und 1 Zeile Ausgabe):

Code: (dl )
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)

View full thread Integer-Maske