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
d79493e5
Commit
d79493e5
authored
Nov 19, 2019
by
Victor Zverovich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove Grisu2
parent
78842ce0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
32 deletions
+12
-32
include/fmt/format-inl.h
include/fmt/format-inl.h
+11
-31
include/fmt/format.h
include/fmt/format.h
+1
-1
No files found.
include/fmt/format-inl.h
View file @
d79493e5
...
@@ -44,10 +44,6 @@
...
@@ -44,10 +44,6 @@
# define FMT_CATCH(x) if (false)
# define FMT_CATCH(x) if (false)
#endif
#endif
#ifndef FMT_ENABLE_GRISU2
# define FMT_ENABLE_GRISU2 0
#endif
#ifdef _MSC_VER
#ifdef _MSC_VER
# pragma warning(push)
# pragma warning(push)
# pragma warning(disable : 4702) // unreachable code
# pragma warning(disable : 4702) // unreachable code
...
@@ -929,7 +925,7 @@ struct fixed_handler {
...
@@ -929,7 +925,7 @@ struct fixed_handler {
};
};
// The shortest representation digit handler.
// The shortest representation digit handler.
template
<
int
GRISU_VERSION
>
struct
grisu_shortest_handler
{
struct
grisu_shortest_handler
{
char
*
buf
;
char
*
buf
;
int
size
;
int
size
;
// Distance between scaled value and upper bound (wp_W in Grisu3).
// Distance between scaled value and upper bound (wp_W in Grisu3).
...
@@ -955,11 +951,6 @@ template <int GRISU_VERSION> struct grisu_shortest_handler {
...
@@ -955,11 +951,6 @@ template <int GRISU_VERSION> struct grisu_shortest_handler {
uint64_t
error
,
int
exp
,
bool
integral
)
{
uint64_t
error
,
int
exp
,
bool
integral
)
{
buf
[
size
++
]
=
digit
;
buf
[
size
++
]
=
digit
;
if
(
remainder
>=
error
)
return
digits
::
more
;
if
(
remainder
>=
error
)
return
digits
::
more
;
if
(
const_check
(
GRISU_VERSION
!=
3
))
{
uint64_t
d
=
integral
?
diff
:
diff
*
data
::
powers_of_10_64
[
-
exp
];
round
(
d
,
divisor
,
remainder
,
error
);
return
digits
::
done
;
}
uint64_t
unit
=
integral
?
1
:
data
::
powers_of_10_64
[
-
exp
];
uint64_t
unit
=
integral
?
1
:
data
::
powers_of_10_64
[
-
exp
];
uint64_t
up
=
(
diff
-
1
)
*
unit
;
// wp_Wup
uint64_t
up
=
(
diff
-
1
)
*
unit
;
// wp_Wup
round
(
up
,
divisor
,
remainder
,
error
);
round
(
up
,
divisor
,
remainder
,
error
);
...
@@ -1113,27 +1104,16 @@ bool grisu_format(Double value, buffer<char>& buf, int precision,
...
@@ -1113,27 +1104,16 @@ bool grisu_format(Double value, buffer<char>& buf, int precision,
upper
=
upper
*
cached_pow
;
// \tilde{M}^+ in Grisu.
upper
=
upper
*
cached_pow
;
// \tilde{M}^+ in Grisu.
assert
(
min_exp
<=
upper
.
e
&&
upper
.
e
<=
-
32
);
assert
(
min_exp
<=
upper
.
e
&&
upper
.
e
<=
-
32
);
auto
result
=
digits
::
result
();
auto
result
=
digits
::
result
();
int
size
=
0
;
--
lower
.
f
;
// \tilde{M}^- - 1 ulp -> M^-_{\downarrow}.
if
(
const_check
(
FMT_ENABLE_GRISU2
&&
++
upper
.
f
;
// \tilde{M}^+ + 1 ulp -> M^+_{\uparrow}.
(
options
&
grisu_options
::
grisu2
)
!=
0
))
{
// Numbers outside of (lower, upper) definitely do not round to value.
++
lower
.
f
;
// \tilde{M}^- + 1 ulp -> M^-_{\uparrow}.
grisu_shortest_handler
handler
{
buf
.
data
(),
0
,
(
upper
-
normalized
).
f
};
--
upper
.
f
;
// \tilde{M}^+ - 1 ulp -> M^+_{\downarrow}.
result
=
grisu_gen_digits
(
upper
,
upper
.
f
-
lower
.
f
,
exp
,
handler
);
grisu_shortest_handler
<
2
>
handler
{
buf
.
data
(),
0
,
(
upper
-
normalized
).
f
};
int
size
=
handler
.
size
;
result
=
grisu_gen_digits
(
upper
,
upper
.
f
-
lower
.
f
,
exp
,
handler
);
if
(
result
==
digits
::
error
)
{
size
=
handler
.
size
;
exp
=
exp
+
size
-
cached_exp10
-
1
;
assert
(
result
!=
digits
::
error
);
fallback_format
(
value
,
buf
,
exp
);
}
else
{
return
true
;
--
lower
.
f
;
// \tilde{M}^- - 1 ulp -> M^-_{\downarrow}.
++
upper
.
f
;
// \tilde{M}^+ + 1 ulp -> M^+_{\uparrow}.
// Numbers outside of (lower, upper) definitely do not round to value.
grisu_shortest_handler
<
3
>
handler
{
buf
.
data
(),
0
,
(
upper
-
normalized
).
f
};
result
=
grisu_gen_digits
(
upper
,
upper
.
f
-
lower
.
f
,
exp
,
handler
);
size
=
handler
.
size
;
if
(
result
==
digits
::
error
)
{
exp
=
exp
+
size
-
cached_exp10
-
1
;
fallback_format
(
value
,
buf
,
exp
);
return
true
;
}
}
}
buf
.
resize
(
to_unsigned
(
size
));
buf
.
resize
(
to_unsigned
(
size
));
}
}
...
...
include/fmt/format.h
View file @
d79493e5
...
@@ -1204,7 +1204,7 @@ template <typename Char> class grisu_writer {
...
@@ -1204,7 +1204,7 @@ template <typename Char> class grisu_writer {
};
};
namespace
grisu_options
{
namespace
grisu_options
{
enum
{
fixed
=
1
,
grisu2
=
2
,
binary32
=
4
};
enum
{
fixed
=
1
,
binary32
=
2
};
}
}
// Formats value using the Grisu algorithm:
// Formats value using the Grisu algorithm:
...
...
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