Skip to content

Commit

Permalink
fix naming inconsistency and fix aliasing in bn_flt_epsilon()
Browse files Browse the repository at this point in the history
  • Loading branch information
brlcad committed Feb 1, 2024
1 parent 0911b56 commit 5197d07
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/libbn/ulp.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ extern int isinf(double x);


double
bn_epsilon(void)
bn_dbl_epsilon(void)
{
#if defined(DBL_EPSILON)
return DBL_EPSILON;
Expand All @@ -61,7 +61,7 @@ bn_epsilon(void)
long long ll;
} val;
val.d = 1.0;
val.ll += 1;
val.ll += 1LL;
return val.d - 1.0;
#else
/* static for computed epsilon so it's only calculated once. */
Expand All @@ -82,7 +82,7 @@ bn_epsilon(void)


float
bn_epsilonf(void)
bn_flt_epsilon(void)
{
#if defined(FLT_EPSILON)
return FLT_EPSILON;
Expand All @@ -92,7 +92,7 @@ bn_epsilonf(void)
long long ll;
} val;
val.f = 1.0;
val.ll += 1;
val.ll += 1LL;
return val.f - 1.0;
#else
/* static for computed epsilon so it's only calculated once. */
Expand Down Expand Up @@ -137,9 +137,13 @@ bn_dbl_max(void)
#if defined(DBL_MAX)
return DBL_MAX;
#elif defined(INFINITY)
static const double val = INFINITY;
long long next = *(long long*)&val - 1;
return *(double *)&next;
union {
double d;
long long ll;
} val;
val.d = INFINITY;
val.ll -= 1LL;
return val.d;
#else
static double max_val = 0.0;

Expand Down

0 comments on commit 5197d07

Please sign in to comment.