0

Number is always represented with the closest double?
A real number is usually between two double representation.
Always the closest representation is used or not necessary?

3
Contributors
4
Replies
5
Views
7 Years
Discussion Span
Last Post by Ancient Dragon
0

My question is:
Every built in operators (+-*/) and math functions (like: sin, cos, sqrt, ...)
acts on floating point numbers a way like the result is rounded to the nearest representable floating point number?

0

C++ does not require that, but the IEEE floating-point standard does. So if you're using C++ on an IEEE-conforming machine, it will behave as you want; otherwise you get what you get.

0

The numbers are not rounded -- excess digits that won't fit in the size of the float or double are just dropped (truncated). Thus if the actual value is 1.236 but only three digits fit in the variable than the variable's value will be 1.23.

Here is a more thorough and accurate description of the problem.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.