Why should I use 2 additions to compare two doubles instead of comparing their differences with the epsilon meaning?

Link here and here ... Why should I use two add-ons using the epsilon method? It seems that the epsilon method would be good enough for most cases.


Update: I'm just looking for a theoretical reason why you would use one over the other. I have always used the epsilon method.

Has anyone used a comparison with two add-ons? What for? Why not?

+3
source share
6 answers

the second link you refer to mentions an article with a rather long description of the problem:

http://www.cygnus-software.com/papers/comparingfloats/comparingfloats.htm

, epsilon,

+3

, .

:

GA, - - ?

, ?

EDIT:

, , , , .

, , NeverWinter Nights (, BioWare). ASCII. ASCII . , , - BioWare, ASCII, . BioWare. . , EPSILONS (, ..), - twos. , EPSILON.

, , . , , . .

EDIT:

LOL, .

, , , epsilon ? .

1e23 1.0001e23 epsilon - 1e-23 5.2e-23 epsilon? , epsilon, ( ).

epsilon .

, , :

" , ... , ".

, :

" , , ".

, , , , , , , , .

+2

. , (, ) , . , , optomise.

+2

, :

  • , .
  • , .

.

0

. , .

. , - . , , . . .

0

, , , . , (1/2, 1/4, 1/8, 1/65536, & c), . , , .

float third = 1/3; float two = 2.0; float another_two = third * 6.0; if (two! = another_two) print ("Zoom in! \ n");

The only time bitwise will be compared will work when you print floating point numbers in exactly the same way, or they are exact representations (integers, fractional power of two). Even then, there may be several representations of some numbers, although I have never seen this in a working system.

0
source

Source: https://habr.com/ru/post/1697156/


All Articles