Skip to content

Commit fb34bfb

Browse files
committed
Don't use compile-time long double arithmetic in src/gentables
1 parent 21bb831 commit fb34bfb

5 files changed

Lines changed: 6 additions & 5 deletions

File tree

src/gentables/fluid_cb2amp.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#include "utils/fluid_conv_tables.h"
33
#include "gentables/ConstExprArr.hpp"
44

5+
#define GCEM_E static_cast<double>(2.7182818284590452353602874713526624977572L)
56
#include "gcem.hpp"
67

78
struct Cb2AmpFunctor
@@ -13,7 +14,7 @@ struct Cb2AmpFunctor
1314
* between 0 and 144 dB. Therefore a negative attenuation is
1415
* not allowed.
1516
*/
16-
return gcem::pow(10.0L, static_cast<fluid_real_t>(i) / -200.0L);
17+
return gcem::pow(10.0, static_cast<fluid_real_t>(i) / -200.0);
1718
}
1819
};
1920

src/gentables/fluid_concave.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ struct ConcaveFunctor
1414
? 0
1515
: ((i == FLUID_VEL_CB_SIZE - 1)
1616
? 1
17-
: ((-200.0L * 2 / FLUID_PEAK_ATTENUATION) * gcem::log(((FLUID_VEL_CB_SIZE - 1) - i) / (FLUID_VEL_CB_SIZE - 1.0L)) / GCEM_LOG_10)
17+
: ((-200.0 * 2 / FLUID_PEAK_ATTENUATION) * gcem::log(((FLUID_VEL_CB_SIZE - 1) - i) / (FLUID_VEL_CB_SIZE - 1.0)) / static_cast<double>(GCEM_LOG_10))
1818
));
1919
}
2020
};

src/gentables/fluid_convex.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ struct ConvexFunctor
1414
? 0
1515
: ((i == FLUID_VEL_CB_SIZE - 1)
1616
? 1
17-
: (1.0L - ((-200.0L * 2 / FLUID_PEAK_ATTENUATION) * gcem::log(i / (FLUID_VEL_CB_SIZE - 1.0L)) / GCEM_LOG_10))
17+
: (1.0 - ((-200.0 * 2 / FLUID_PEAK_ATTENUATION) * gcem::log(i / (FLUID_VEL_CB_SIZE - 1.0)) / static_cast<double>(GCEM_LOG_10)))
1818
));
1919
}
2020
};

src/gentables/fluid_interp_coeff_sinc7.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ struct InterpSincFunctor
6666
#define I (i % SINC_INTERP_ORDER)
6767
#define x ((fluid_real_t)I_NUM / (fluid_real_t)FLUID_INTERP_MAX)
6868
#define I_SHIFTED ((fluid_real_t)I - ((fluid_real_t)SINC_INTERP_ORDER / 2.0) + (fluid_real_t)(FLUID_INTERP_MAX - I2 - 1) / (fluid_real_t)FLUID_INTERP_MAX)
69-
#define ARG (GCEM_PI * I_SHIFTED)
69+
#define ARG (static_cast<double>(GCEM_PI) * I_SHIFTED)
7070

7171
return gcem::fabs(I_SHIFTED) > 0.000001
7272
? (gcem::sin(ARG) / (ARG)) * (0.5 * (1.0 + gcem::cos(2.0 * ARG / (fluid_real_t)SINC_INTERP_ORDER)))

src/gentables/fluid_pan.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ struct PanFunctor
99
static constexpr fluid_real_t calc(int i)
1010
{
1111
/* initialize the pan conversion table */
12-
return static_cast<fluid_real_t>(gcem::sin(i * (GCEM_HALF_PI / (FLUID_PAN_SIZE - 1.0L))));
12+
return static_cast<fluid_real_t>(gcem::sin(i * (static_cast<double>(GCEM_HALF_PI) / (FLUID_PAN_SIZE - 1.0))));
1313
}
1414
};
1515

0 commit comments

Comments
 (0)