From 84a26de9ae9ade8629dee53cac8b9357f0930690 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Cl=C3=A9ment=20de=20l=27Hamaide?= Date: Tue, 30 Dec 2014 16:04:33 +0100 Subject: [PATCH] Altimeter: fix output format for hPa/InHg settings 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 | 8 ++++---- src/Instrumentation/altimeter.hxx | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Instrumentation/altimeter.cxx b/src/Instrumentation/altimeter.cxx index a691f1e90..00e6bb4b3 100644 --- a/src/Instrumentation/altimeter.cxx +++ b/src/Instrumentation/altimeter.cxx @@ -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; } diff --git a/src/Instrumentation/altimeter.hxx b/src/Instrumentation/altimeter.hxx index 45c3a4e61..a9b32d9a4 100644 --- a/src/Instrumentation/altimeter.hxx +++ b/src/Instrumentation/altimeter.hxx @@ -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; -- 2.39.5