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
d7f17613
Commit
d7f17613
authored
Sep 26, 2018
by
Victor Zverovich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix compilation on platforms with exotic double (#878)
parent
e4ca37cc
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
5 deletions
+18
-5
include/fmt/format-inl.h
include/fmt/format-inl.h
+6
-3
include/fmt/format.h
include/fmt/format.h
+7
-2
test/format-impl-test.cc
test/format-impl-test.cc
+5
-0
No files found.
include/fmt/format-inl.h
View file @
d7f17613
...
@@ -513,7 +513,8 @@ FMT_FUNC void grisu2_gen_digits(
...
@@ -513,7 +513,8 @@ FMT_FUNC void grisu2_gen_digits(
}
}
}
}
FMT_FUNC
void
grisu2_format_positive
(
double
value
,
char
*
buffer
,
size_t
&
size
,
template
<
typename
Double
>
FMT_FUNC
void
grisu2_format_positive
(
Double
value
,
char
*
buffer
,
size_t
&
size
,
int
&
dec_exp
)
{
int
&
dec_exp
)
{
FMT_ASSERT
(
value
>
0
,
"value is nonpositive"
);
FMT_ASSERT
(
value
>
0
,
"value is nonpositive"
);
fp
fp_value
(
value
);
fp
fp_value
(
value
);
...
@@ -640,8 +641,10 @@ FMT_FUNC void grisu2_prettify(char *buffer, size_t &size, int exp,
...
@@ -640,8 +641,10 @@ FMT_FUNC void grisu2_prettify(char *buffer, size_t &size, int exp,
// Formats a nonnegative value using Grisu2 algorithm. Grisu2 doesn't give any
// Formats a nonnegative value using Grisu2 algorithm. Grisu2 doesn't give any
// guarantees on the shortness of the result.
// guarantees on the shortness of the result.
FMT_FUNC
void
grisu2_format
(
double
value
,
char
*
buffer
,
size_t
&
size
,
char
type
,
template
<
typename
Double
>
int
precision
,
bool
write_decimal_point
)
{
FMT_FUNC
typename
std
::
enable_if
<
sizeof
(
Double
)
==
sizeof
(
uint64_t
)
>::
type
grisu2_format
(
Double
value
,
char
*
buffer
,
size_t
&
size
,
char
type
,
int
precision
,
bool
write_decimal_point
)
{
FMT_ASSERT
(
value
>=
0
,
"value is negative"
);
FMT_ASSERT
(
value
>=
0
,
"value is negative"
);
int
dec_exp
=
0
;
// K in Grisu.
int
dec_exp
=
0
;
// K in Grisu.
if
(
value
>
0
)
{
if
(
value
>
0
)
{
...
...
include/fmt/format.h
View file @
d7f17613
...
@@ -293,8 +293,13 @@ inline bool use_grisu() {
...
@@ -293,8 +293,13 @@ inline bool use_grisu() {
// Formats value using Grisu2 algorithm:
// Formats value using Grisu2 algorithm:
// https://www.cs.tufts.edu/~nr/cs257/archive/florian-loitsch/printf.pdf
// https://www.cs.tufts.edu/~nr/cs257/archive/florian-loitsch/printf.pdf
FMT_API
void
grisu2_format
(
double
value
,
char
*
buffer
,
size_t
&
size
,
char
type
,
template
<
typename
Double
>
int
precision
,
bool
write_decimal_point
);
FMT_API
typename
std
::
enable_if
<
sizeof
(
Double
)
==
sizeof
(
uint64_t
)
>::
type
grisu2_format
(
Double
value
,
char
*
buffer
,
size_t
&
size
,
char
type
,
int
precision
,
bool
write_decimal_point
);
template
<
typename
Double
>
inline
typename
std
::
enable_if
<
sizeof
(
Double
)
!=
sizeof
(
uint64_t
)
>::
type
grisu2_format
(
Double
,
char
*
,
size_t
&
,
char
,
int
,
bool
)
{}
template
<
typename
Allocator
>
template
<
typename
Allocator
>
typename
Allocator
::
value_type
*
allocate
(
Allocator
&
alloc
,
std
::
size_t
n
)
{
typename
Allocator
::
value_type
*
allocate
(
Allocator
&
alloc
,
std
::
size_t
n
)
{
...
...
test/format-impl-test.cc
View file @
d7f17613
...
@@ -102,6 +102,11 @@ TEST(FPTest, GetCachedPower) {
...
@@ -102,6 +102,11 @@ TEST(FPTest, GetCachedPower) {
}
}
}
}
TEST
(
FPTest
,
Grisu2FormatCompilesWithNonIEEEDouble
)
{
size_t
size
=
0
;
fmt
::
internal
::
grisu2_format
(
4.2
f
,
FMT_NULL
,
size
,
0
,
0
,
false
);
}
template
<
typename
T
>
template
<
typename
T
>
struct
ValueExtractor
:
fmt
::
internal
::
function
<
T
>
{
struct
ValueExtractor
:
fmt
::
internal
::
function
<
T
>
{
T
operator
()(
T
value
)
{
T
operator
()(
T
value
)
{
...
...
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