]> git.mxchange.org Git - flightgear.git/commitdiff
Altimeter: fix output format for hPa/InHg settings
authorClément de l'Hamaide <clemaez@hotmail.fr>
Tue, 30 Dec 2014 15:04:33 +0000 (16:04 +0100)
committerClément de l'Hamaide <clemaez@hotmail.fr>
Tue, 30 Dec 2014 15:20:08 +0000 (16:20 +0100)
Usually, in a real cockpit, altimeter shows hPa setting as an integer number and InHg setting is limited to 2 decimals

In aviation we don't need higher numeric precision

src/Instrumentation/altimeter.cxx
src/Instrumentation/altimeter.hxx

index a691f1e90814d7f77180eb7845a4c2087edcb5af..00e6bb4b366e1dd5dd62885f7bdc6bf1b6e9fecf 100644 (file)
@@ -52,7 +52,7 @@ Altimeter::~Altimeter ()
 double
 Altimeter::getSettingInHg() const
 {
-    return _settingInHg;
+    return int(_settingInHg*100.0)/100.0; /* return only 2 decimals: xx.xx */
 }
 
 void
@@ -61,14 +61,14 @@ Altimeter::setSettingInHg( double value )
     _settingInHg = value;
 }
 
-double
+int
 Altimeter::getSettingHPa() const
 {
-    return _settingInHg * SG_INHG_TO_PA / 100;
+    return int(_settingInHg * SG_INHG_TO_PA / 100.0); /* return an INT: xxxx */
 }
 
 void
-Altimeter::setSettingHPa( double value )
+Altimeter::setSettingHPa( int value )
 {
     _settingInHg = value * SG_PA_TO_INHG * 100;
 }
index 45c3a4e61260e4da7b89d2426fc49b00ab3cb64f..a9b32d9a412ba02c80c0ee91326002c1a6260d10 100644 (file)
@@ -43,8 +43,8 @@ public:
 
     double getSettingInHg() const;
     void setSettingInHg( double value );
-    double getSettingHPa() const;
-    void setSettingHPa( double value );
+    int getSettingHPa() const;
+    void setSettingHPa( int value );
 
 private:
     std::string _name;