Comparing structures, ignoring floating point roundoff differences
am 18.11.2005 20:07:55 von Joseph Brenner
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?
Re: Comparing structures, ignoring floating point roundoff differences
am 18.11.2005 21:39:24 von Jim Gibson
In article , Joseph Brenner
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