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.
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
Improvements to FixedDecimal f64 APIs #1718
Improvements to FixedDecimal f64 APIs #1718
Changes from all commits
42cd434
33d6849
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
suggestion
: It would be useful to have the same number with different DoublePrecisions to compare the result.If that's not feasible, than some description on when to use which (either here or by each variant of the enum), would help.
The way it reads now seems like I should chose my prevision variant depending on the value, rather than on the output.
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.
Thanks for the suggestion; I will implement this, but
I argue that it is, in fact, dependent on the value. What you're doing is filling in "metadata" about the value that the
f64
type is incapable of carrying internally.Do you have suggestions on how to improve the docs to convey that subtlety?
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 don't and maybe I'm misguided, but I think of myself as a perfect target audience for this docs.
I am an engineer, I have code that may have floats (example: user provides temperature in celsius) and I need to get plural category using it.
I don't have deep understanding of the problem space and I come to docs looking for
TryFrom<f64>
. Instead I find this new notion ofDoublePrecision
and the library authors ask me to pick a variant.I don't know how and which one to use when. They can say "36.6 celsius","2.5 celsius", "25 celsius", "16.5 celsius" or "-10.2 celsius".
Doc string stating
Specify that the floating point number is integer-valued.
is confusing. I don't understand what does it mean for a float point number to be an integer-values. Will the float from the user be integer valued?Next
Magnitude
- I can guess maybe that the doc string tells me that I can specify how many fration digits there will be in the output, but I'm not sure.Next is
SignificantDigits
- how are significant digits different from magnitude? fraction digits?Finally,
Floating
tells me that it'll have precision to maximum of IEEE - what's IEEE?I may be overpainting here, but I think it's worth assuming the developer knows as little as I presented above.
Multiple examples by each variant showing what happens to several numbers under each variant would help visually distinguish the end result.
I think we're asking a lot from developers and forcing them to think in ways they often don't. Adding docs will be super valuable to educate them rather than frustrate.
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'm not totally aligned. An engineer in such a situation should have a NumberFormat, and they should be getting the plural form of the formatted number, not the input double.
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 see. I don't think we have a
FormattedNumber
type yet, so for now people will come with af64
.Also, independently of my scenario, the docs should help someone understand the difference between variants and help them select the right one based on their needs in scenarios where they do not understand the nuances.
I think the current wording of the doc assumes quite detailed understanding of the details.