Discussion
When a variable of data type double is converted into float, then
Answer: A
Correct answer: Rounding takes place
Narrowing a double to a float is a value conversion, not a reinterpretation of bits. If the value cannot be represented exactly in single precision, the result is one of the two nearest representable values, chosen according to the current rounding mode - normally to nearest.
So it is rounding rather than truncation, and describing it as dropping the low-order bits is wrong in both senses: the exponent field differs too, and mantissa bits are rounded rather than discarded. If the magnitude is too large for float, the result is infinity.
Post your comment
Please log in or register to post a comment.
Examination Categories
- SSC Exams
- Banking Exams
- Teaching Exams
- Civil Services Exams
- Railways Exams
- Engineering Recruitment Exams
- Defence Exams
- State Government Exams
- Police Exams
- Insurance Exams
- Nursing Exams
- Other Government Exams
- NRA CET
- PG Entrance Exams
- Campus Placement
- MBA Entrance Exams
- CUET and UG Entrance
- Judiciary Exams
- Regulatory Body Exams
- Software Development