-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Try a new formatting algorithm for float/double with a small given precision #3262
Comments
Yes.
It is the number of digits to generate or -1 for the shortest number of digits that round trip. We need to adjust it from the user-specified precision for a number of reasons:
-1 is just a special value that denotes the shortest roundtrip format to distinguish it from nonnegative values that specify "fixed" precision.
If
Right. |
Thanks for the info.
I guess, except for the fixed-point format, in case we need to adjust it with the decimal exponent, right? |
That's right. |
I'm presuming that calling Another question. It looks like in the Grisu-path, the size of the buffer is only modified after all the digits are written to the buffer. Do you pre-modify the size of the buffer into something big enough, and then only shrink it in |
Accidently closed, sorry. |
Looks correct. Sorry I forgot about
Grisu can only generate small(ish) number of digits, fewer than
Very cool! |
So this is a continuation from the discussion done here: #2750.
I'm trying to implement the plan discussed but currently a little bit confused.
format_float
which produces actual digits for the input floating-point number, and it does not print the decimal dot, and it does not attempt to choose between fixed / scientific form. It just print digits to a buffer, and later on in another function up in the call stack it is adjusted according to the precise spec. Is that the right understanding?precision
offormat_float
is different from the precision given by the input. What exactly is that number? Why, for example, we decide shortest roundtrip output ifprecision
is negative? Ultimately, what we need is the number of digits to print, counted from the first nonzero digit. How can I get that number?format_float
, right? So can I assume that the input is not zero if it passed over the branchif (value <= 0)
?The text was updated successfully, but these errors were encountered: