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:
- Encoding int value as an IEEE-754 float (binary32)
- What is Bit Masking?
- What does the statement if (counter & (1
- Decimal to Binary
- What is bit masking?
- Are the shift operators () arithmetic or logical in C?
- ‘float’ vs. ‘double’ precision
- Are the results of bitwise operations on signed integers defined?
- Operator precedence (bitwise ‘&’ lower than ‘==’)
- Bitfield manipulation in C
- Fastest way to clamp a real (fixed/floating point) value?
- What’s the use of suffix `f` on float value
- How to convert string to float?
- How to extract the decimal part from a floating point number in C?
- C: Casting minimum 32-bit integer (-2147483648) to float gives positive number (2147483648.0)
- Convert double/float to string
- Ranges of floating point datatype in C?
- Bitshift and integer promotion?
- C: How to wrap a float to the interval [-pi, pi)
- How to define and work with an array of bits in C?
- Implementing Logical Right Shift in C
- sin, cos, tan and rounding error
- Algorithm to generate bit mask
- What precisely does the %g printf specifier mean?
- Check if a number is non zero using bitwise operators in C
- Is there a document describing how Clang handles excess floating-point precision?
- Can you control what a bitwise right shift will fill in C?
- Why do you need an explicit `-lm` compiler option? [duplicate]
- C fundamentals: double variable not equal to double expression?
- How can floating point calculations be made deterministic?