-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
lots of 'minor' fixes lol, plus a huge overhaul of arithmetic and vec…
…tors (#10) * lots of 'minor' fixes lol, plus a huge overhaul of arithmetic and vectors * fix const-qualified member preventing copy construction * fixed implicit cast warnings * fixed more implicit conversion warnings
- Loading branch information
1 parent
14afa46
commit 7b6d28d
Showing
20 changed files
with
865 additions
and
85 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,7 +1,7 @@ | ||
#pragma once | ||
|
||
#include "Rect.hpp" | ||
#include "Constants.hpp" | ||
#include "Rect.hpp" | ||
|
||
namespace kn | ||
{ | ||
|
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
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 |
---|---|---|
@@ -0,0 +1,75 @@ | ||
#ifndef MATH_OVERFLOW_HPP | ||
#define MATH_OVERFLOW_HPP | ||
|
||
#include <cmath> | ||
#include <limits> | ||
#include <stdint.h> | ||
|
||
#include "Constants.hpp" | ||
|
||
namespace kn | ||
{ | ||
|
||
namespace Overflow | ||
{ | ||
|
||
//@{ | ||
/** | ||
* @brief Checks if an overflow would occur in summation | ||
* | ||
* @param first first value | ||
* @param second second value | ||
* @return true if sum is valid, false otherwise | ||
*/ | ||
bool isSumValid(const float64_t& first, const float64_t& second); | ||
|
||
bool isSumValid(const float32_t& first, const float32_t& second); | ||
|
||
bool isSumValid(const uint32_t& first, const uint32_t& second); | ||
|
||
bool isSumValid(const uint64_t& first, const uint64_t& second); | ||
|
||
bool isSumValid(const int32_t& first, const int32_t& second); | ||
|
||
bool isSumValid(const int64_t& first, const int64_t& second); | ||
//@} | ||
|
||
//@{ | ||
/** | ||
* @brief Checks if an overflow would occur in multiplcation | ||
* | ||
* @param first first value | ||
* @param second second value | ||
* @return true if product is valid, false otherwise | ||
*/ | ||
bool isProductValid(const float64_t& first, const float64_t& second); | ||
|
||
bool isProductValid(const float32_t& first, const float32_t& second); | ||
|
||
bool isProductValid(const uint32_t& first, const uint32_t& second); | ||
|
||
bool isProductValid(const uint64_t& first, const uint64_t& second); | ||
|
||
bool isProductValid(const int32_t& first, const int32_t& second); | ||
|
||
bool isProductValid(const int64_t& first, const int64_t& second); | ||
//@} | ||
|
||
//@{ | ||
/** | ||
* @brief Checks if the value is close to zero | ||
* | ||
* @param value value to check | ||
* @param tolerance the accuracy to use, anything closer to 0 than this will be considered zero | ||
* @return true if close to zero, false otherwise | ||
*/ | ||
bool closeToZero(const float64_t& value, const float64_t tolerance = 0.0001); | ||
|
||
bool closeToZero(const float32_t& value, const float32_t tolerance = 0.0001f); | ||
//@} | ||
|
||
} // namespace Overflow | ||
|
||
} // namespace kn | ||
|
||
#endif // MATH_OVERFLOW_HPP |
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.