diff options
author | Christian Hammacher <bmasterc@gmail.com> | 2021-10-28 14:58:32 +0300 |
---|---|---|
committer | Christian Hammacher <bmasterc@gmail.com> | 2021-10-28 14:58:32 +0300 |
commit | 4f218659e714355d7d2c79bc5d455323ab463081 (patch) | |
tree | 36ec0b7ddaaa04726095095afa9a1dcc52fa9d05 /src/ObjectModel | |
parent | 8207b22cc13e7893ae1cb43f4aef4a7632cac5b3 (diff) | |
parent | c2073e0b5177dd0bd111f40bdff7adf6bd9d38de (diff) |
Merge remote-tracking branch 'origin/3.4-dev' into v3-chrishamm
Diffstat (limited to 'src/ObjectModel')
-rw-r--r-- | src/ObjectModel/ObjectModel.cpp | 14 | ||||
-rw-r--r-- | src/ObjectModel/ObjectModel.h | 2 |
2 files changed, 15 insertions, 1 deletions
diff --git a/src/ObjectModel/ObjectModel.cpp b/src/ObjectModel/ObjectModel.cpp index 165431e4..938479ae 100644 --- a/src/ObjectModel/ObjectModel.cpp +++ b/src/ObjectModel/ObjectModel.cpp @@ -193,6 +193,20 @@ void ExpressionValue::Release() noexcept } } +// Get the format string to use assuming this is a floating point number +const char *ExpressionValue::GetFloatFormatString() const noexcept +{ + float f = 1.0; + unsigned int digitsAfterPoint = param; + while (digitsAfterPoint > 1 && fVal > f) + { + f *= 10.0; + --digitsAfterPoint; + } + + return ::GetFloatFormatString(digitsAfterPoint); +} + #if SUPPORT_CAN_EXPANSION // Given that this is a CanExpansionBoardDetails value, extract the part requested according to the parameter and append it to the string diff --git a/src/ObjectModel/ObjectModel.h b/src/ObjectModel/ObjectModel.h index 3202aa54..9ae99e80 100644 --- a/src/ObjectModel/ObjectModel.h +++ b/src/ObjectModel/ObjectModel.h @@ -194,7 +194,7 @@ struct ExpressionValue #endif // Get the format string to use assuming this is a floating point number - const char *GetFloatFormatString() const noexcept { return ::GetFloatFormatString(param); } + const char *GetFloatFormatString() const noexcept; // Append a string representation of this value to a string void AppendAsString(const StringRef& str) const noexcept; |