-
Notifications
You must be signed in to change notification settings - Fork 69
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
A class to represent an approximate quantity #2285
Conversation
error_representation.size() >= 2 && | ||
error_representation[0] == '0' && | ||
(error_representation[1] == 'x' || error_representation[1] == 'X'); | ||
for (int i = 0; i < error_representation.size(); ++i) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that this would be more readable if we were building error_representation
(by looping on representation
and appending) than rewriting it with 0s; either way, add a comment describing what we are doing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would not be more readable because I would need more state variables to copy the exponent without patching it. Added a comment.
return ApproximateQuantity<double>::Parse(representation, /*ulp=*/8); | ||
} | ||
|
||
ApproximateQuantity<double> operator""_⑼(char const* const representation) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we are going to do this beyond ⑴, add 🄐 .. 🄕 as well (morally they should CHECK
for a hexadecimal representation
but I am OK with trusting the sanity of the author here).
Maybe invest in a macro to factor the definitions?
Historical note: the parenthesized letters were encoded for compatibility with an ARIB standard https://www.unicode.org/wg2/docs/n3469.pdf (they are ARIB 9433..9458); some of the parenthesized digits are also present in that standard (ARIB 9417..9428), though they stop at 12 in ARIB (the parenthesized digits are from Unicode 1.1, so the rationale for their encoding may be lost to time).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, with check and macro.
First part of addressing #2269.