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
bed134a4
Commit
bed134a4
authored
Feb 27, 2020
by
Victor Zverovich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Tentative fix for default template param in friend error
parent
b2d3a86e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
21 deletions
+20
-21
include/fmt/format-inl.h
include/fmt/format-inl.h
+20
-21
No files found.
include/fmt/format-inl.h
View file @
bed134a4
...
@@ -336,6 +336,10 @@ class fp {
...
@@ -336,6 +336,10 @@ class fp {
private:
private:
using
significand_type
=
uint64_t
;
using
significand_type
=
uint64_t
;
public:
significand_type
f
;
int
e
;
// All sizes are in bits.
// All sizes are in bits.
// Subtract 1 to account for an implicit most significant bit in the
// Subtract 1 to account for an implicit most significant bit in the
// normalized form.
// normalized form.
...
@@ -343,11 +347,6 @@ class fp {
...
@@ -343,11 +347,6 @@ class fp {
std
::
numeric_limits
<
double
>::
digits
-
1
;
std
::
numeric_limits
<
double
>::
digits
-
1
;
static
FMT_CONSTEXPR_DECL
const
uint64_t
implicit_bit
=
static
FMT_CONSTEXPR_DECL
const
uint64_t
implicit_bit
=
1ULL
<<
double_significand_size
;
1ULL
<<
double_significand_size
;
public:
significand_type
f
;
int
e
;
static
FMT_CONSTEXPR_DECL
const
int
significand_size
=
static
FMT_CONSTEXPR_DECL
const
int
significand_size
=
bits
<
significand_type
>::
value
;
bits
<
significand_type
>::
value
;
...
@@ -358,22 +357,6 @@ class fp {
...
@@ -358,22 +357,6 @@ class fp {
// errors on platforms where double is not IEEE754.
// errors on platforms where double is not IEEE754.
template
<
typename
Double
>
explicit
fp
(
Double
d
)
{
assign
(
d
);
}
template
<
typename
Double
>
explicit
fp
(
Double
d
)
{
assign
(
d
);
}
// Normalizes the value converted from double and multiplied by (1 << SHIFT).
template
<
int
SHIFT
>
friend
fp
normalize
(
fp
value
)
{
// Handle subnormals.
const
auto
shifted_implicit_bit
=
fp
::
implicit_bit
<<
SHIFT
;
while
((
value
.
f
&
shifted_implicit_bit
)
==
0
)
{
value
.
f
<<=
1
;
--
value
.
e
;
}
// Subtract 1 to account for hidden bit.
const
auto
offset
=
fp
::
significand_size
-
fp
::
double_significand_size
-
SHIFT
-
1
;
value
.
f
<<=
offset
;
value
.
e
-=
offset
;
return
value
;
}
// Assigns d to this and return true iff predecessor is closer than successor.
// Assigns d to this and return true iff predecessor is closer than successor.
template
<
typename
Double
,
FMT_ENABLE_IF
(
sizeof
(
Double
)
==
sizeof
(
uint64_t
))>
template
<
typename
Double
,
FMT_ENABLE_IF
(
sizeof
(
Double
)
==
sizeof
(
uint64_t
))>
bool
assign
(
Double
d
)
{
bool
assign
(
Double
d
)
{
...
@@ -434,6 +417,22 @@ class fp {
...
@@ -434,6 +417,22 @@ class fp {
}
}
};
};
// Normalizes the value converted from double and multiplied by (1 << SHIFT).
template
<
int
SHIFT
>
fp
normalize
(
fp
value
)
{
// Handle subnormals.
const
auto
shifted_implicit_bit
=
fp
::
implicit_bit
<<
SHIFT
;
while
((
value
.
f
&
shifted_implicit_bit
)
==
0
)
{
value
.
f
<<=
1
;
--
value
.
e
;
}
// Subtract 1 to account for hidden bit.
const
auto
offset
=
fp
::
significand_size
-
fp
::
double_significand_size
-
SHIFT
-
1
;
value
.
f
<<=
offset
;
value
.
e
-=
offset
;
return
value
;
}
inline
bool
operator
==
(
fp
x
,
fp
y
)
{
return
x
.
f
==
y
.
f
&&
x
.
e
==
y
.
e
;
}
inline
bool
operator
==
(
fp
x
,
fp
y
)
{
return
x
.
f
==
y
.
f
&&
x
.
e
==
y
.
e
;
}
// Computes lhs * rhs / pow(2, 64) rounded to nearest with half-up tie breaking.
// Computes lhs * rhs / pow(2, 64) rounded to nearest with half-up tie breaking.
...
...
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