Since **winIDEA build 9.11.69 **the **precision of floating point comparisons **is **adjustable**.

When would that affect you? Well, every time you calculate with floating point numbers...

A **floating point** number is represented in a computer by **several significant digits **used for the number and an **exponent**, both in **binary format**. A definite dezimal number e.g. 0,1 can have an indefinite periodic binary representation e.g. 0,0001100110011. In a computer only the **first digits of that periodic number are stored** which may lead to **inaccurateness in calculations**, e.g. will 10*0,1 in a computer result in 1,0? Well, it depends on the implementation...

Modern computers have additional to the main CPU (e.g. using 64 bits) a floating point unit (FPU e.g. using 80 bits). Assume you assign x=y=1; and compare cos(x) == cos(y); It can happen that this comparison is not true if cos(x) has been **buffered** (in memory 64 bit and therefore **rounded**) while cos(y) has been processed directly from the FPU (80 bit and was not rounded).

To solve this dilemma you can set the **tolerable error due to rounding** in floating point arithmetic - the so called **machine epsilon**. When you calculate the absolute error of a floating point comparison, it must be smaller or equal to epsilon (float x, y;): **(x-y)<=epsilon**

Since winIDEA build 9.11.69 you can now set the value for ** Floating point compare precision **in menu

**Debug/ Debug Options/ Symbols.**

## Comments

You can follow this conversation by subscribing to the comment feed for this post.