Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   C Programming (http://www.velocityreviews.com/forums/f42-c-programming.html)
-   -   Quasi 0 (http://www.velocityreviews.com/forums/t946542-quasi-0-a.html)

 David RF 06-04-2012 09:32 AM

Quasi 0

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 06-04-2012 09:56 AM

Re: Quasi 0

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 06-04-2012 10:05 AM

Re: Quasi 0

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 06-04-2012 10:38 AM

Re: Quasi 0

David RF <davranfor@gmail.com> 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 06-04-2012 10:51 AM

Re: Quasi 0

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
esosman@ieee-dot-org.invalid

 David RF 06-04-2012 10:56 AM

Re: Quasi 0

On 4 jun, 12:51, Eric Sosman <esos...@ieee-dot-org.invalid> 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 06-04-2012 11:08 AM

Re: Quasi 0

"David RF" <davranfor@gmail.com> wrote in message
news:bfad6935-b012-44b5-b5ce-bd10814d8aaf@t8g2000yqd.googlegroups.com...
> On 4 jun, 12:51, Eric Sosman <esos...@ieee-dot-org.invalid> 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 06-04-2012 11:10 AM

Re: Quasi 0

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 06-04-2012 11:14 AM

Re: Quasi 0

On 4 jun, 13:08, "BartC" <b...@freeuk.com> wrote:
> "David RF" <davran...@gmail.com> wrote in message
>
> news:bfad6935-b012-44b5-b5ce-bd10814d8aaf@t8g2000yqd.googlegroups.com...
>
>
>
> > On 4 jun, 12:51, Eric Sosman <esos...@ieee-dot-org.invalid> 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 06-04-2012 11:25 AM

Re: Quasi 0

On Jun 4, 5:56Â*pm, David RF <davran...@gmail.com> 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

This is in reply to BartC, who asks "What happened?"

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

All times are GMT. The time now is 04:43 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.