Not knowing the test data which makes it fails, I can only suggest
a couple of things:
First, why consider floats equal if their difference is less than
some tolerance? Why not just compare them and let the natural comparison
dictate less than, equal or greater than? i.e.,
if (f1 == f2)
return 0;
if (f1 < f2)
return -1;
return 1;
Also, is it possible that atof() is failing but that the error
is not being detected and that is causing problems? If so, try strtod() instead
and add code to handle the errors?
- Chris
From:
wireshark-dev-bounces@xxxxxxxxxxxxx [mailto:wireshark-dev-bounces@xxxxxxxxxxxxx]
On Behalf Of Anders Broman
Sent: Tuesday, February 17, 2009 3:42 AM
To: Developer support list for Wireshark
Subject: [Wireshark-dev] Sorting floats?
Hi,
The following
code in rtp_analysis.c
case 4:
f1=atof(text1);
f2=atof(text2);
if (fabs(f1-f2)<0.0000005)
return 0;
if (f1<f2)
return -1;
return 1;
Is used to sort
floats but it seems not to give the right result. Does any one know how to fix
it?
Regards
Anders