Skip to content

Commit

Permalink
[SYCL] Prevent use of double in stream implementation (#7234)
Browse files Browse the repository at this point in the history
The current implementation of stream uses double literals for some
generalized floating point operations. To avoid this inadvertently
requiring support for fp64, this commit makes appropriate conversions.

Signed-off-by: Larsen, Steffen <steffen.larsen@intel.com>
  • Loading branch information
steffenlarsen committed Nov 2, 2022
1 parent 8ca7d50 commit a67807a
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions sycl/include/sycl/stream.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -265,14 +265,14 @@ EnableIfFP<T, unsigned> floatingPointToDecStr(T AbsVal, char *Digits,
int Exp = 0;

// For the case that the value is larger than 10.0
while (AbsVal >= 10.0) {
while (AbsVal >= T{10.0}) {
++Exp;
AbsVal /= 10.0;
AbsVal /= T{10.0};
}
// For the case that the value is less than 1.0
while (AbsVal > 0.0 && AbsVal < 1.0) {
while (AbsVal > T{0.0} && AbsVal < T{1.0}) {
--Exp;
AbsVal *= 10.0;
AbsVal *= T{10.0};
}

auto IntegralPart = static_cast<int>(AbsVal);
Expand All @@ -292,7 +292,7 @@ EnableIfFP<T, unsigned> floatingPointToDecStr(T AbsVal, char *Digits,
FractionLength = MAX_FLOATING_POINT_DIGITS - 5;

for (unsigned I = 0; I < FractionLength; ++I) {
FractionPart *= 10.0;
FractionPart *= T{10.0};
FractionDigits[I] = static_cast<int>(FractionPart);
FractionPart -= static_cast<int>(FractionPart);
}
Expand Down

0 comments on commit a67807a

Please sign in to comment.