Add real-valued (double) temperature types#3
Merged
Conversation
Add celsius_real, kelvin_real, and fahrenheit_real: double-precision
temperatures whose count() reads directly in scale degrees. Their
std::formatter specializations render the degree value with the scale
suffix (e.g. "22.5°C") and honor the standard floating-point format spec
("{:.1f}" -> "22.5°C"). Convert an exact reading with a cast, e.g.
temperature_cast<celsius_real>(millicelsius(22500)).
Include <version> before the std::format feature-test check so the
formatter block is enabled in standalone (non-IDF) builds, where nothing
pulls in __cpp_lib_format beforehand.
5914892 to
0873647
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add real-valued double-precision temperature types —
celsius_real,kelvin_real, andfahrenheit_real— whosecount()reads directly in scale degrees. Theirstd::formatterspecializations render the degree value with the scale suffix (22.5°C) and honor the standard floating-point format spec ({:.1f}→22.5°C). The intended use is to cast an exact reading to a real-valued type for display or floating-point computation, e.g.temperature_cast<celsius_real>(millicelsius(22500)).Also include
<version>before thestd::formatfeature-test check, so the formatter block is enabled in standalone (non-IDF) builds where nothing pulls in__cpp_lib_formatfirst.Version 1.3.0.