Given the following in C++(you might be surprised):
unsigned short x=0xFFFF;
unsigned short y=0xFFFF;
auto z=x*y;
std::cout << z;
Without checking, assuming an LP64 system what is the result:
A. 4294836225
B. -131071
C. fffe0001
D. Undefined behavior
#Cplusplus
#Cpppolls
-
Prikaži ovu nit
-
First of all big h/t to
@Myriachan whom I learned this devious example from
The answer is D, this is undefined behavior but how you might protest, unsigned number don’t have undefined behavior on overflow, do they?6 replies 3 proslijeđena tweeta 19 korisnika označava da im se sviđaPrikaži ovu nit
@cjdb_ns
@hashpling
@pathofshrines
@stoiandan22
@graymalk
@DanielKhoshnoud
@beached_whale
@sikraemer
@janwilmans
@dascandy42
@mrkkrj
@dloginov
@desdotdev
@zizzivon
@sehetw
@kfsone
@weskerfoot
@FPiednoel
@varseand
@getowled
@mxanathar
@horenmar_ctu
@MalwareMinigun
@arek_fu
22:50 - 30. sij 2020.
0 replies
0 proslijeđenih tweetova
5 korisnika označava da im se sviđa
Čini se da učitavanje traje već neko vrijeme.
Twitter je možda preopterećen ili ima kratkotrajnih poteškoća u radu. Pokušajte ponovno ili potražite dodatne informacije u odjeljku Status Twittera.