C has the “union” to handle this type of view of data:
typedef union {
int i;
float f;
} u;
u u1;
u1.f = 45.6789;
/* now u1.i refers to the int version of the float */
printf("%d",u1.i);
More Related Contents:
- Casting float to int (bitwise) in C
- What is Bit Masking?
- What does the statement if (counter & (1
- Decimal to Binary
- What is bit masking?
- Bit manipulation, return 0 if x != 0, or nonzero otherwise
- Why does >= operator work as > operator in C when compared with 0.9 [duplicate]
- How do you set, clear, and toggle a single bit?
- Correct format specifier for double in printf
- Arithmetic bit-shift on a signed integer
- How to get the sign, mantissa and exponent of a floating point number
- Fast computing of log2 for 64-bit integers
- Extracting bits with a single multiplication
- Simd matmul program gives different numerical results
- Floating point comparison `a != 0.7` [duplicate]
- C: Casting minimum 32-bit integer (-2147483648) to float gives positive number (2147483648.0)
- Are floating point operations in C associative?
- Bitshift and integer promotion?
- Is my fma() broken?
- Bit twiddling: which bit is set?
- C – Serialization of the floating point numbers (floats, doubles)
- Variadic function (va_arg) doesn’t work with float?
- Why does printf print random value with float and integer format specifier
- How do I get bit-by-bit data from an integer value in C?
- How does this bitwise operation check for a power of 2?
- Bitwise shifting array of char’s
- clang 14.0.0 floating point optimizations
- Conditional tests in primality by trial division
- How to set, clear, and toggle a single bit?
- How to implement Bitcount using only Bitwise operators?