This is the fixed line:
Note short type instead of int.
EMG
ui = ( ( short * )( &d ) )[3] & 0xfff0; // Get exponentNote short type instead of int.
EMG