Re: Comparing structures, ignoring floating point roundoff differences



In article <m3acg16agk.fsf@xxxxxxxxxxxxxxxxxxxxxx>, Joseph Brenner
<doom@xxxxxxxxxxxxxxxxx> wrote:

> I've got a problem where I need to compare structures that have
> floating point numbers stashed in them. I want to test the
> structures for identity (ala is_deeply from Test::More), but
> ignore tiny differences in the floating point numbers.
>
> This seems like something that ought to be a solved problem by
> now, but I'm having trouble finding it. I had some hopes for
> Test::Deep, which at least has a "num" comparison operation where
> you can set a tolerance to ignore, but it looks to me like that's
> only for comparing a computed value to an expected constant
> value: I need to compare computed values that are expected to
> match each other.
>
> Does that ring any bells with anyone?

The module Test::Number::Delta allows you to compare two floating-point
values within a specified precision.

Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
.



Relevant Pages

  • Comparing structures, ignoring floating point roundoff differences
    ... I've got a problem where I need to compare structures that have ... ignore tiny differences in the floating point numbers. ... only for comparing a computed value to an expected constant ...
    (comp.lang.perl.modules)
  • Re: Comparing floating point values in Java
    ... when comparing floating point values in computers. ... In Java, will unchanged values compare strictly true if equal? ... In strictfp mode, the exact, bit-by-bit, result is predictable from the ...
    (comp.lang.java.programmer)
  • Re: Comparing floating point values in Java
    ... when comparing floating point values in computers. ... In Java, will unchanged values compare strictly true if equal? ... In strictfp mode, the exact, bit-by-bit, result is predictable from the ...
    (comp.lang.java.programmer)
  • Re: addition of 0.7 and 0.1 is not 0.8 CDbl / CStr vbs problem
    ... Comparing floating point values should be done using a tolerance:- ... In other cases the resulting 'near enough' value stored after a calculation ... the situation using CDbl) than to compare with "almost near ... CStr may no longer be what you want. ...
    (microsoft.public.scripting.vbscript)
  • Re: Can anyone repeat this?
    ... incrementing and decrementing by .01 (as represented by the compiler), ... Not a good idea to compare floating points like this though. ...
    (microsoft.public.vc.mfc)