реорганизация функций проекта, уменьшение дублирующегося кода

This commit is contained in:
Andrey Pokidov 2025-02-04 13:20:46 +07:00
parent 6c0ae92ed4
commit 07623b2aa6
10 changed files with 84 additions and 67 deletions

View file

@ -4,7 +4,6 @@
#define BGC_EPSYLON_EFFECTIVENESS_LIMIT_FP32 10.0f
#define BGC_EPSYLON_FP32 5E-7f
#define BGC_TWO_EPSYLON_FP32 1E-6f
#define BGC_SQUARE_EPSYLON_FP32 2.5E-13f
#define BGC_ONE_THIRD_FP32 0.333333333f
@ -17,7 +16,6 @@
#define BGC_EPSYLON_EFFECTIVENESS_LIMIT_FP64 10.0
#define BGC_EPSYLON_FP64 5E-14
#define BGC_TWO_EPSYLON_FP64 1E-13
#define BGC_SQUARE_EPSYLON_FP64 2.5E-27
#define BGC_ONE_THIRD_FP64 0.333333333333333333
@ -27,6 +25,39 @@
#define BGC_GOLDEN_RATIO_HIGH_FP64 1.61803398874989485
#define BGC_GOLDEN_RATIO_LOW_FP64 0.61803398874989485
inline int bgc_is_zero_fp32(const float square_value)
{
return (-BGC_EPSYLON_FP32 <= square_value) && (square_value <= BGC_EPSYLON_FP32);
}
inline int bgc_is_zero_fp64(const double square_value)
{
return (-BGC_EPSYLON_FP64 <= square_value) && (square_value <= BGC_EPSYLON_FP64);
}
inline int bgc_is_unit_fp32(const float square_value)
{
return (1.0f - BGC_EPSYLON_FP32 <= square_value) && (square_value <= 1.0f + BGC_EPSYLON_FP32);
}
inline int bgc_is_unit_fp64(const double square_value)
{
return (1.0 - BGC_EPSYLON_FP64 <= square_value) && (square_value <= 1.0 + BGC_EPSYLON_FP64);
}
inline int bgc_is_sqare_value_unit_fp32(const float square_value)
{
return (1.0f - 2.0f * BGC_EPSYLON_FP32 <= square_value) && (square_value <= 1.0f + 2.0f * BGC_EPSYLON_FP32);
}
inline int bgc_is_sqare_value_unit_fp64(const double square_value)
{
return (1.0 - 2.0 * BGC_EPSYLON_FP64 <= square_value) && (square_value <= 1.0 + 2.0 * BGC_EPSYLON_FP64);
}
inline int bgc_are_equal_fp32(const float value1, const float value2)
{
if (-BGC_EPSYLON_EFFECTIVENESS_LIMIT_FP32 < value1 && value1 < BGC_EPSYLON_EFFECTIVENESS_LIMIT_FP32) {