79689700

Date: 2025-07-04 05:35:43
Score: 1
Natty:
Report link

You're seeing different outputs because a union shares the same memory for all members. When you set myUnion.floatValue = 84.0, it stores the IEEE-754 binary representation of 84.0 (hex 42A80000 = decimal 1118306304).

Accessing myUnion.intValue interprets those same bytes as an integer (yielding 1118306304), not a converted value. The (int)84.0 cast performs actual conversion (to 84).

charValue reads only the first byte of this float, not 84 or 'T'

Reasons:
  • No code block (0.5):
  • Low reputation (0.5):
Posted by: Shivam Bhosle