Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
F
fmt
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
fmt
Commits
0016da7a
Commit
0016da7a
authored
Sep 19, 2020
by
Victor Zverovich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Don't generate zeros and fix UB on huge precision
parent
ce3f7699
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
4 deletions
+5
-4
include/fmt/format-inl.h
include/fmt/format-inl.h
+5
-4
No files found.
include/fmt/format-inl.h
View file @
0016da7a
...
...
@@ -2612,10 +2612,7 @@ void fallback_format(Double d, int num_digits, bool binary32, buffer<char>& buf,
if
(
upper
!=
&
lower
)
*
upper
*=
10
;
}
}
// Generate the given number of digits up to the maximum possible number of
// significant digits in an IEEE754 double.
const
int
max_double_digits
=
767
;
if
(
num_digits
>
max_double_digits
)
num_digits
=
max_double_digits
;
// Generate the given number of digits.
exp10
-=
num_digits
-
1
;
if
(
num_digits
==
0
)
{
buf
.
try_resize
(
1
);
...
...
@@ -2745,6 +2742,10 @@ int format_float(T value, int precision, float_specs specs, buffer<char>& buf) {
const
auto
cached_pow
=
get_cached_power
(
min_exp
-
(
normalized
.
e
+
fp
::
significand_size
),
cached_exp10
);
normalized
=
normalized
*
cached_pow
;
// Limit precision to the maximum possible number of significant digits in an
// IEEE754 double because we don't need to generate zeros.
const
int
max_double_digits
=
767
;
if
(
precision
>
max_double_digits
)
precision
=
max_double_digits
;
fixed_handler
handler
{
buf
.
data
(),
0
,
precision
,
-
cached_exp10
,
fixed
};
if
(
grisu_gen_digits
(
normalized
,
1
,
exp
,
handler
)
==
digits
::
error
)
{
exp
+=
handler
.
size
-
cached_exp10
-
1
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment