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
aa729bf2
Commit
aa729bf2
authored
Sep 22, 2020
by
Victor Zverovich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove dead code
parent
aa2ddf9b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
0 additions
and
78 deletions
+0
-78
include/fmt/format-inl.h
include/fmt/format-inl.h
+0
-28
test/format-impl-test.cc
test/format-impl-test.cc
+0
-50
No files found.
include/fmt/format-inl.h
View file @
aa729bf2
...
@@ -1154,34 +1154,6 @@ class fp {
...
@@ -1154,34 +1154,6 @@ class fp {
*
this
=
fp
();
*
this
=
fp
();
return
false
;
return
false
;
}
}
// Assigns d to this together with computing lower and upper boundaries,
// where a boundary is a value half way between the number and its predecessor
// (lower) or successor (upper). The upper boundary is normalized and lower
// has the same exponent but may be not normalized.
template
<
typename
Double
>
boundaries
assign_with_boundaries
(
Double
d
)
{
bool
is_lower_closer
=
assign
(
d
);
fp
lower
=
is_lower_closer
?
fp
((
f
<<
2
)
-
1
,
e
-
2
)
:
fp
((
f
<<
1
)
-
1
,
e
-
1
);
// 1 in normalize accounts for the exponent shift above.
fp
upper
=
normalize
<
1
>
(
fp
((
f
<<
1
)
+
1
,
e
-
1
));
lower
.
f
<<=
lower
.
e
-
upper
.
e
;
return
boundaries
{
lower
.
f
,
upper
.
f
};
}
template
<
typename
Double
>
boundaries
assign_float_with_boundaries
(
Double
d
)
{
assign
(
d
);
constexpr
int
min_normal_e
=
std
::
numeric_limits
<
float
>::
min_exponent
-
std
::
numeric_limits
<
double
>::
digits
;
significand_type
half_ulp
=
1
<<
(
std
::
numeric_limits
<
double
>::
digits
-
std
::
numeric_limits
<
float
>::
digits
-
1
);
if
(
min_normal_e
>
e
)
half_ulp
<<=
min_normal_e
-
e
;
fp
upper
=
normalize
<
0
>
(
fp
(
f
+
half_ulp
,
e
));
fp
lower
=
fp
(
f
-
(
half_ulp
>>
((
f
==
implicit_bit
&&
e
>
min_normal_e
)
?
1
:
0
)),
e
);
lower
.
f
<<=
lower
.
e
-
upper
.
e
;
return
boundaries
{
lower
.
f
,
upper
.
f
};
}
};
};
// Normalizes the value converted from double and multiplied by (1 << SHIFT).
// Normalizes the value converted from double and multiplied by (1 << SHIFT).
...
...
test/format-impl-test.cc
View file @
aa729bf2
...
@@ -186,29 +186,6 @@ template <bool is_iec559> void run_double_tests() {
...
@@ -186,29 +186,6 @@ template <bool is_iec559> void run_double_tests() {
template
<
>
void
run_double_tests
<
true
>
()
{
template
<
>
void
run_double_tests
<
true
>
()
{
// Construct from double.
// Construct from double.
EXPECT_EQ
(
fp
(
1.23
),
fp
(
0x13ae147ae147aeu
,
-
52
));
EXPECT_EQ
(
fp
(
1.23
),
fp
(
0x13ae147ae147aeu
,
-
52
));
// Compute boundaries:
fp
value
;
// Normalized & not power of 2 - equidistant boundaries:
auto
b
=
value
.
assign_with_boundaries
(
1.23
);
EXPECT_EQ
(
value
,
fp
(
0x0013ae147ae147ae
,
-
52
));
EXPECT_EQ
(
b
.
lower
,
0x9d70a3d70a3d6c00
);
EXPECT_EQ
(
b
.
upper
,
0x9d70a3d70a3d7400
);
// Normalized power of 2 - lower boundary is closer:
b
=
value
.
assign_with_boundaries
(
1.9807040628566084e+28
);
// 2**94
EXPECT_EQ
(
value
,
fp
(
0x0010000000000000
,
42
));
EXPECT_EQ
(
b
.
lower
,
0x7ffffffffffffe00
);
EXPECT_EQ
(
b
.
upper
,
0x8000000000000400
);
// Smallest normalized double - equidistant boundaries:
b
=
value
.
assign_with_boundaries
(
2.2250738585072014e-308
);
EXPECT_EQ
(
value
,
fp
(
0x0010000000000000
,
-
1074
));
EXPECT_EQ
(
b
.
lower
,
0x7ffffffffffffc00
);
EXPECT_EQ
(
b
.
upper
,
0x8000000000000400
);
// Subnormal - equidistant boundaries:
b
=
value
.
assign_with_boundaries
(
4.9406564584124654e-324
);
EXPECT_EQ
(
value
,
fp
(
0x0000000000000001
,
-
1074
));
EXPECT_EQ
(
b
.
lower
,
0x4000000000000000
);
EXPECT_EQ
(
b
.
upper
,
0xc000000000000000
);
}
}
TEST
(
FPTest
,
DoubleTests
)
{
TEST
(
FPTest
,
DoubleTests
)
{
...
@@ -222,33 +199,6 @@ TEST(FPTest, Normalize) {
...
@@ -222,33 +199,6 @@ TEST(FPTest, Normalize) {
EXPECT_EQ
(
-
6
,
normalized
.
e
);
EXPECT_EQ
(
-
6
,
normalized
.
e
);
}
}
TEST
(
FPTest
,
ComputeFloatBoundaries
)
{
struct
{
double
x
,
lower
,
upper
;
}
tests
[]
=
{
// regular
{
1.5
f
,
1.4999999403953552
,
1.5000000596046448
},
// boundary
{
1.0
f
,
0.9999999701976776
,
1.0000000596046448
},
// min normal
{
1.1754944e-38
f
,
1.1754942807573643e-38
,
1.1754944208872107e-38
},
// max subnormal
{
1.1754942e-38
f
,
1.1754941406275179e-38
,
1.1754942807573643e-38
},
// min subnormal
{
1e-45
f
,
7.006492321624085e-46
,
2.1019476964872256e-45
},
};
for
(
auto
test
:
tests
)
{
fp
vlower
=
normalize
(
fp
(
test
.
lower
));
fp
vupper
=
normalize
(
fp
(
test
.
upper
));
vlower
.
f
>>=
vupper
.
e
-
vlower
.
e
;
vlower
.
e
=
vupper
.
e
;
fp
value
;
auto
b
=
value
.
assign_float_with_boundaries
(
test
.
x
);
EXPECT_EQ
(
vlower
.
f
,
b
.
lower
);
EXPECT_EQ
(
vupper
.
f
,
b
.
upper
);
}
}
TEST
(
FPTest
,
Multiply
)
{
TEST
(
FPTest
,
Multiply
)
{
auto
v
=
fp
(
123ULL
<<
32
,
4
)
*
fp
(
56ULL
<<
32
,
7
);
auto
v
=
fp
(
123ULL
<<
32
,
4
)
*
fp
(
56ULL
<<
32
,
7
);
EXPECT_EQ
(
v
.
f
,
123u
*
56u
);
EXPECT_EQ
(
v
.
f
,
123u
*
56u
);
...
...
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