Velocity Reviews > Quasi 0

# Quasi 0

David RF
Guest
Posts: n/a

 06-04-2012
Hi friends:
Machine epsilon is the maximum relative error of the chosen rounding
procedure

#include <stdio.h>
#include <math.h>
#include <float.h>

int main(void)
{
double a = 0.1;
double b = 0.1;

a += 1.0;
a -= 1.0;

printf("a == b = %s\n", a == b ? "equals" : "unequals");
printf("a == b = %s\n", fabs(a - b) < DBL_EPSILON ? "equals" :
"unequals");
return 0;
}

Is this a good method for test the equality?

Noob
Guest
Posts: n/a

 06-04-2012
David RF wrote:

> Is this a good method for test the equality?

If you're bored on a rainy afternoon, you can read David Goldberg's
looong article on FP arithmetic.

http://docs.oracle.com/cd/E19957-01/..._goldberg.html

David RF
Guest
Posts: n/a

 06-04-2012
On 4 jun, 11:56, Noob <r...@127.0.0.1> wrote:
> David RF wrote:
> > Is this a good method for test the equality?

>
> If you're bored on a rainy afternoon, you can read David Goldberg's
> looong article on FP arithmetic.
>
> http://docs.oracle.com/cd/E19957-01/..._goldberg.html

Can you link to someone else's website where formulas do not mix
letters and numbers?

Stefan Ram
Guest
Posts: n/a

 06-04-2012
David RF <(E-Mail Removed)> writes:
>Is this a good method for test the equality?

To test equality of two double values, use »==«.
(Another question is when or whether this is appropriate.)

Eric Sosman
Guest
Posts: n/a

 06-04-2012
On 6/4/2012 5:32 AM, David RF wrote:
> Hi friends:
> Machine epsilon is the maximum relative error of the chosen rounding
> procedure
>
> #include<stdio.h>
> #include<math.h>
> #include<float.h>
>
> int main(void)
> {
> double a = 0.1;
> double b = 0.1;
>
> a += 1.0;
> a -= 1.0;
>
> printf("a == b = %s\n", a == b ? "equals" : "unequals");
> printf("a == b = %s\n", fabs(a - b)< DBL_EPSILON ? "equals" :
> "unequals");
> return 0;
> }
>
> Is this a good method for test the equality?

No.

Rounding adds or subtracts an amount that is proportional to
the magnitude of the rounded number. DBL_EPSILON is scaled for
numbers near +-1, but is of completely the wrong size for numbers
around +-1E30 or +-1E-30. DBL_EPSILON is about 1E-16 on many
machines, so consider the values 1E-20 and 1E-30: They differ
by much less than the typical DBL_EPSILON, yet one is ten billion
times the other. Do you want to consider a ten billion-fold
discrepancy "equal?"

--
Eric Sosman
http://www.velocityreviews.com/forums/(E-Mail Removed)d

David RF
Guest
Posts: n/a

 06-04-2012
On 4 jun, 12:51, Eric Sosman <(E-Mail Removed)> wrote:
> El 04/06/2012 05:32 AM, David RF escribiÃ³:
>
>
>
>
>
>
>
> > Hola amigos:

> Epsilon> de la mÃ¡quina es el mÃ¡ximo error relativo de redondeo elegido
> > Procedimiento de

>
> > # Include
> > # Include <math.h>
> > # Include <float.h>

>
> > Int main (void)
> > {
> > Doble a = 0,1;
> > Doble b = 0,1;

>
> > A + = 1.0;
> > A - = 1,0;

>
> > Printf ("a == b =% s â€‹â€‹\ n", un "igual" == b:"desiguales"?);
> > Printf ("a == b =% s â€‹â€‹\ n", fÃ¡bricas (a - b) <DBL_EPSILON "iguales"?
> > "Desiguales");
> > Return 0;
> >}

>
> > Â¿Es este un buen mÃ©todo para la prueba de la igualdad?

>
> No.
>
> Completan suma o resta una cantidad que es proporcional a
> la magnitud del nÃºmero redondeado. DBL_EPSILON se escala para la
> nÃºmeros de cerca de + -1, pero es por completo de la talla equivocada de los nÃºmeros
> alrededor de + o +-1e30-1E-30. DBL_EPSILON se trata de 1E-16 en muchosmÃ¡quinas, a fin de considerar los valores 1E-20 y 1E-30: Se diferencian
> por mucho menos que el DBL_EPSILON tÃ*pica, sin embargo, uno es diez mil millones
> veces el otro. Â¿Quieres tener en cuenta un niÃ±o de diez mil millones de veces
> discrepancia "iguales?"

Thanks, I get the point

BartC
Guest
Posts: n/a

 06-04-2012

"David RF" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> On 4 jun, 12:51, Eric Sosman <(E-Mail Removed)> wrote:
>> El 04/06/2012 05:32 AM, David RF escribiÃ³:

>> > Hola amigos:

>> Epsilon> de la mÃ¡quina es el mÃ¡ximo error relativo de redondeo elegido
>> > Procedimiento de

>>
>> > # Include
>> > # Include <math.h>
>> > # Include <float.h>

>>
>> > Int main (void)
>> > {
>> > Doble a = 0,1;
>> > Doble b = 0,1;

>>
>> > A + = 1.0;
>> > A - = 1,0;

>>
>> > Printf ("a == b =% s â€‹â€‹\ n", un "igual" == b: "desiguales"?);
>> > Printf ("a == b =% s â€‹â€‹\ n", fÃ¡bricas (a - b) <DBL_EPSILON "iguales"?
>> > "Desiguales");
>> > Return 0;
>> >}

>>
>> > Â¿Es este un buen mÃ©todo para la prueba de la igualdad?

>>
>> No.
>>
>> Completan suma o resta una cantidad que es proporcional a
>> la magnitud del nÃºmero redondeado. DBL_EPSILON se escala para la
>> nÃºmeros de cerca de + -1, pero es por completo de la talla equivocada de
>> los nÃºmeros
>> alrededor de + o +-1e30-1E-30. DBL_EPSILON se trata de 1E-16 en
>> muchosmÃ¡quinas, a fin de considerar los valores 1E-20 y 1E-30: Se
>> diferencian
>> por mucho menos que el DBL_EPSILON tÃ*pica, sin embargo, uno es diez mil
>> millones
>> veces el otro. Â¿Quieres tener en cuenta un niÃ±o de diez mil millones de
>> veces
>> discrepancia "iguales?"

>
> Thanks, I get the point

What happened there?

--
Bartc

James Kuyper
Guest
Posts: n/a

 06-04-2012
On 06/04/2012 06:05 AM, David RF wrote:
> On 4 jun, 11:56, Noob <r...@127.0.0.1> wrote:
>> David RF wrote:
>>> Is this a good method for test the equality?

>>
>> If you're bored on a rainy afternoon, you can read David Goldberg's
>> looong article on FP arithmetic.
>>
>> http://docs.oracle.com/cd/E19957-01/..._goldberg.html

>
> Can you link to someone else's website where formulas do not mix
> letters and numbers?

Such formulas are the clearest and most natural way to describe the
concepts being discussed. If your mathematical background is not
sufficiently advanced for you to be able to understand such formulas,
it's also insufficient to understand the corresponding concepts. You
should wait until you've learned some algebra before attempting to read
things like this. If you've already tried to learn algebra, and came
away with an aversion to it, you should consider avoiding technically
oriented career paths such as computer programming.
--
James Kuyper

David RF
Guest
Posts: n/a

 06-04-2012
On 4 jun, 13:08, "BartC" <(E-Mail Removed)> wrote:
> "David RF" <(E-Mail Removed)> wrote in message
>
> news:(E-Mail Removed)...
>
>
>
> > On 4 jun, 12:51, Eric Sosman <(E-Mail Removed)> wrote:
> >> El 04/06/2012 05:32 AM, David RF escribiÃ³:
> >> > Hola amigos:
> >> Epsilon> de la mÃ¡quina es el mÃ¡ximo error relativo de redondeo elegido
> >> > Procedimiento de

>
> >> > # Include
> >> > # Include <math.h>
> >> > # Include <float.h>

>
> >> > Int main (void)
> >> > {
> >> > Doble a = 0,1;
> >> > Doble b = 0,1;

>
> >> > A + = 1.0;
> >> > A - = 1,0;

>
> >> > Printf ("a == b =% s â€‹â€‹\ n", un "igual" ==b: "desiguales"?);
> >> > Printf ("a == b =% s â€‹â€‹\ n", fÃ¡bricas (a - b) <DBL_EPSILON "iguales"?
> >> > "Desiguales");
> >> > Return 0;
> >> >}

>
> >> > Â¿Es este un buen mÃ©todo para la prueba de la igualdad?

>
> >> No.

>
> >> Completan suma o resta una cantidad que es proporcional a
> >> la magnitud del nÃºmero redondeado. DBL_EPSILON se escala para la
> >> nÃºmeros de cerca de + -1, pero es por completo de la talla equivocada de
> >> los nÃºmeros
> >> alrededor de + o +-1e30-1E-30. DBL_EPSILON se trata de 1E-16 en
> >> muchosmÃ¡quinas, a fin de considerar los valores 1E-20 y 1E-30: Se
> >> diferencian
> >> por mucho menos que el DBL_EPSILON tÃ*pica, sin embargo, uno es diez mil
> >> millones
> >> veces el otro. Â¿Quieres tener en cuenta un niÃ±o de diez mil millones de
> >> veces
> >> discrepancia "iguales?"

>
> > Thanks, I get the point

>
> What happened there?

Oops, excuse me, I replied to Eric after using the translator

James Dow Allen
Guest
Posts: n/a

 06-04-2012
On Jun 4, 5:56Â*pm, David RF <(E-Mail Removed)> wrote:
> On June 4, 12:51, Eric Sosman <those...@ ieee-dot-org.invalid> wrote:
>
>
>
>
>
>
>
> > On 04/06/2012 5:32 a.m., David RF wrote:

>
> >> Hello friends:

> > Epsilon> machine is the maximum relative error of rounding chosen

> Procedure >>
>
> >> # Include# Include <math.h> >>

> # Include <float.h> >>
>
> >> Int main (void)

> {>>
> Turn >> = 0.1;
> Double >> b = 0.1;
>
> >> A + = 1.0;
> >> A - = 1.0;

>
> >> Printf ("a == b =% s â€‹â€‹\ n", an "equal" == b"unequal"?)
> >> Printf ("a == b =% s â€‹â€‹\ n", factories (a - b) <DBL_EPSILON "equal"?
> >> "Unequal");
> >> Return 0;
> >>}

>
> >> Is this a good method to test for equality?

>
> > No.

>
> > Rounding adds or subtracts an amount which is proportional to
> > The sheer numbers rounded. DBL_EPSILON is scaled to the
> > Numbers of about + -1, but it is completely the wrong size of the numbers
> > About + or +-1e30-1E-30. DBL_EPSILON is muchosmÃ¡quinas 1E-16 in order to consider the values â€‹â€‹1E-1E-20 and 30: They differ
> > For much less than the typical DBL_EPSILON, however, one is ten billion
> > Times the other. Want to take account of a ten billion times
> > Discrepancy "equal?"

>
> Thanks, I get the point

I respond to David's post, first clicking "Translate to English."
The post now has less Spanish than before (though still doesn't
look like Eric's post).

And this was with *Old* Google Groups.
I've not yet dared to learn what wondrous features
*New* Google Groups has!! ::slaps face with hand::

James