Re: atom = problem?

new topic     » goto parent     » topic index » view thread      » older message » newer message

Jeremy Cowgar wrote:
> 
> CChris wrote:
> > 
> > You shouldn't use string conversion to compare atoms, because of the limited
> > precision of floating point numbers in hardware.
> > Use atom_to_float64() in machine.e instead to obtain a sequence of 8 bytes,
> > which is the internal representation of the number. Then comparing these
> > sequences
> > of equal length becomes unambiguous.
> > 
> 
> I'm not following. Here's what I did:
> 
> }}}
<eucode>
> test_equal("atan2() #1",
> atom_to_float64(1.283713957607754085898932316922582685947418212890625),
>     atom_to_float64(atan2(10.5, 3.1)))
> </eucode>
{{{

> 
> Here's what I get:
> 
>   failed: atan2() #1. expected: {41,129,149,165,23,138,244,63} but got:
>   {42,129,149,165,23,138,244,63}
> 
> 
> --
> Jeremy Cowgar
> <a href="http://jeremy.cowgar.com">http://jeremy.cowgar.com</a>

Ok, I get it better now.
The problem may lie in how the interpreter parses the string
"1.283713957607754085898932316922582685947418212890625". It won't check all
digits.
I'll check tonight at home using Mathematica, and will tell you more precisely
where the error is.
Oh, by the way, do you get the same issue when using atan2(105,31) instead?
Because there is some imprecision in 3.1, as you know (same old "penny issue").

CChris

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu