I'm trying to cast a float to an unsigned int and getting some surprising behavior.
The output of this code changes depending on which compiler I use. Sometimes I get -1 and sometimes I get 0. Not really sure why though.Code:float x = -1.0; unsigned int y = (unsigned int)x; printf("y = %d\n", y);
edit: Tried searching before posting but tried a different search term after posting and found a stackoverflow thread explaining why this is not portable. A bit surprising, but good to know.