Frederic Bouvier schrieb:
Stefan C. Müller a écrit :
* Replaced an rint() call with floor() (MSVC does not offer rint).
I am a bit worried that floor and rint are not the same. I don't know if
it matters in this context but how about using the code below instead ?
// round double to 10^g
double rnd(double r, int g = 0)
{
double f = pow(10.0, g);
double n = r / f;
n += ( n < 0 ) ? -.5 : .5;
return f * floor( n );
}
-Fred
You got me there. It's (only) used for text output so I was a bit lasy.
Here's version 3 of my patch.
You guys give me a tough review. I like that! Thanks for the effort.
Stefan
Index: Airports/simple.cxx
===================================================================
RCS file: /var/cvs/FlightGear-0.9/source/src/Airports/simple.cxx,v
retrieving revision 1.47
diff -u -r1.47 simple.cxx
--- Airports/simple.cxx 24 Aug 2008 09:04:24 -0000 1.47
+++ Airports/simple.cxx 31 Aug 2008 10:47:50 -0000
@@ -335,6 +335,16 @@
{
return mOrdering->compare(aA.first,aB);
}
+
+ bool operator()(const std::string& aA, const airport_map::value_type& aB)
const
+ {
+ return mOrdering->compare(aA, aB.first);
+ }
+
+ bool operator()(const airport_map::value_type& aA, const
airport_map::value_type& aB) const
+ {
+ return mOrdering->compare(aA.first, aB.first);
+ }
private:
FGIdentOrdering* mOrdering;
Index: Main/metar_main.cxx
===================================================================
RCS file: /var/cvs/FlightGear-0.9/source/src/Main/metar_main.cxx,v
retrieving revision 1.13
diff -u -r1.13 metar_main.cxx
--- Main/metar_main.cxx 2 Jun 2008 21:07:38 -0000 1.13
+++ Main/metar_main.cxx 31 Aug 2008 14:24:23 -0000
@@ -24,6 +24,7 @@
#include <sstream>
#include <iostream>
#include <string.h>
+#include <time.h>
#include <simgear/debug/logstream.hxx>
#include <simgear/environment/metar.hxx>
@@ -76,7 +77,7 @@
double rnd(double r, int g = 0)
{
double f = pow(10.0, g);
- return f * rint(r / f);
+ return f * floor(r / f + 0.5); // round to the nearest integer
}
Index: Navaids/fixlist.cxx
===================================================================
RCS file: /var/cvs/FlightGear-0.9/source/src/Navaids/fixlist.cxx,v
retrieving revision 1.14
diff -u -r1.14 fixlist.cxx
--- Navaids/fixlist.cxx 23 Aug 2008 13:09:24 -0000 1.14
+++ Navaids/fixlist.cxx 31 Aug 2008 10:46:18 -0000
@@ -145,6 +145,16 @@
{
return mOrdering->compare(aA.first,aB);
}
+
+ bool operator()(const std::string& aA, const fix_map_type::value_type& aB)
const
+ {
+ return mOrdering->compare(aA, aB.first);
+ }
+
+ bool operator()(const fix_map_type::value_type& aA, const
fix_map_type::value_type& aB) const
+ {
+ return mOrdering->compare(aA.first, aB.first);
+ }
private:
FGIdentOrdering* mOrdering;
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Flightgear-devel mailing list
Flightgear-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/flightgear-devel