Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Formations
Cpp
GettingStartedWithModernCpp
Commits
9056422b
Commit
9056422b
authored
May 13, 2019
by
GILLES Sebastien
Browse files
Exercice 39 solution now compiles...
parent
68026796
Changes
1
Hide whitespace changes
Inline
Side-by-side
TP/4-Templates/Solution/exercice39.cpp
View file @
9056422b
...
...
@@ -184,9 +184,9 @@ IntT operator*(const PowerOfTwoApprox<IntT>& approx, IntT coefficient)
bool
is_overflow
{
false
};
// static_cast for the sake of `short` case: short + short -> int!
IntT
ret
=
static_cast
<
IntT
>
(
times_power_of_2
<
IntT
>
(
is_overflow
,
approx
.
Numerator
()
*
coefficient
,
-
approx
.
Exponent
()));
IntT
ret
=
static_cast
<
IntT
>
(
times_power_of_2
(
is_overflow
,
approx
.
Numerator
()
*
coefficient
,
-
approx
.
Exponent
()));
if
(
is_overflow
)
{
...
...
@@ -438,7 +438,6 @@ void TestDisplaySum<IntT>::Display(int Nbits, double value1, IntT coefficient1,
// Ugly trick to circumvent the fact we can't add a new argument to operator* to get the value of `overflow`
// boolean. Fortunately we'll see a bit later how to deal properly with this.
bool
is_overflow
{
false
};
if
(
approx
==
std
::
numeric_limits
<
IntT
>::
max
())
is_overflow
=
true
;
...
...
Write
Preview
Supports
Markdown
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