Skip to content

Commit

Permalink
Formatted
Browse files Browse the repository at this point in the history
  • Loading branch information
chrysante committed Apr 9, 2023
1 parent a36f95a commit da45e7f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
3 changes: 2 additions & 1 deletion include/APMath/Conversion.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ namespace APMath {
class APInt;
class APFloat;

/// Convert value \p from to the value of type `To` with the same bit representation as \p from
/// Convert value \p from to the value of type `To` with the same bit
/// representation as \p from
template <typename To, typename From>
To bitcast(From const& from); // Undefined

Expand Down
10 changes: 6 additions & 4 deletions src/Conversion.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#include <APMath/Conversion.h>

#include <cassert>
#include <bit>
#include <cassert>

#include <APMath/APInt.h>
#include <APMath/APFloat.h>
#include <APMath/APInt.h>

using namespace APMath;

Expand All @@ -23,9 +23,11 @@ APFloat APMath::bitcast(APInt const& from) {
assert((from.bitwidth() == 32 || from.bitwidth() == 64) &&
"Other sizes are not supported by APFloat");
if (from.bitwidth() == 32) {
return APFloat(std::bit_cast<float>(from.to<uint32_t>()), APFloatPrec::Single);
return APFloat(std::bit_cast<float>(from.to<uint32_t>()),
APFloatPrec::Single);
}
else {
return APFloat(std::bit_cast<double>(from.to<uint64_t>()), APFloatPrec::Double);
return APFloat(std::bit_cast<double>(from.to<uint64_t>()),
APFloatPrec::Double);
}
}

0 comments on commit da45e7f

Please sign in to comment.