-
Notifications
You must be signed in to change notification settings - Fork 99
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
605 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,15 @@ | ||
#pragma once | ||
|
||
//! Fixed point number (With implicit conversion to float) | ||
template<typename T, float CompressValue> | ||
requires std::is_integral_v<T> | ||
template<std::integral T, float CompressValue> | ||
class FixedFloat { | ||
T value{}; | ||
|
||
public: | ||
constexpr FixedFloat() = default; | ||
constexpr FixedFloat(float X) : value(static_cast<T>(X * CompressValue)) {} | ||
explicit constexpr FixedFloat(T X) : value(X) {} | ||
constexpr FixedFloat(float v) : value(static_cast<T>(v * CompressValue)) {} | ||
template<std::integral Y> | ||
constexpr FixedFloat(Y x) : value(x) {} | ||
|
||
constexpr operator float() const { | ||
return static_cast<float>(value) / CompressValue; | ||
} | ||
constexpr operator float() const { return static_cast<float>(value) / CompressValue; } | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.