65 #define literal64bit(longLiteral) (longLiteral##LL)
70 using pointer_sized_int =
int64;
72 using pointer_sized_uint =
uint64;
75 using pointer_sized_int = _W64
int;
77 using pointer_sized_uint = _W64
unsigned int;
85#if JUCE_WINDOWS && ! JUCE_MINGW
93template <
typename Type>
94constexpr Type
jmax (Type
a, Type
b) {
return a <
b ?
b :
a; }
97template <
typename Type>
98constexpr Type
jmax (Type
a, Type
b, Type
c) {
return a <
b ? (
b <
c ?
c :
b) : (
a <
c ?
c :
a); }
101template <
typename Type>
105template <
typename Type>
106constexpr Type
jmin (Type
a, Type
b) {
return b <
a ?
b :
a; }
109template <
typename Type>
110constexpr Type
jmin (Type
a, Type
b, Type
c) {
return b <
a ? (
c <
b ?
c :
b) : (
c <
a ?
c :
a); }
113template <
typename Type>
119template <
typename Type>
120constexpr Type
jmap (Type value0To1, Type targetRangeMin, Type targetRangeMax)
122 return targetRangeMin + value0To1 * (targetRangeMax - targetRangeMin);
126template <
typename Type>
127Type
jmap (Type sourceValue, Type sourceRangeMin, Type sourceRangeMax, Type targetRangeMin, Type targetRangeMax)
129 jassert (sourceRangeMax != sourceRangeMin);
130 return targetRangeMin + ((targetRangeMax - targetRangeMin) * (sourceValue - sourceRangeMin)) / (sourceRangeMax - sourceRangeMin);
143template <
typename Type>
144Type
mapToLog10 (Type value0To1, Type logRangeMin, Type logRangeMax)
149 auto logMin = std::log10 (logRangeMin);
150 auto logMax = std::log10 (logRangeMax);
152 return std::pow ((Type) 10.0, value0To1 * (logMax - logMin) + logMin);
165template <
typename Type>
166Type
mapFromLog10 (Type valueInLogRange, Type logRangeMin, Type logRangeMax)
171 auto logMin = std::log10 (logRangeMin);
172 auto logMax = std::log10 (logRangeMax);
174 return (std::log10 (valueInLogRange) - logMin) / (logMax - logMin);
178template <
typename Type,
typename Size>
186 while (--numValues > 0)
198template <
typename Type,
typename Size>
206 while (--numValues > 0)
218template <
typename Type>
219void findMinAndMax (
const Type* values,
int numValues, Type& lowest, Type& highest)
231 while (--numValues > 0)
261template <
typename Type>
264 Type valueToConstrain)
noexcept
266 jassert (lowerLimit <= upperLimit);
268 return valueToConstrain < lowerLimit ? lowerLimit
269 : (upperLimit < valueToConstrain ? upperLimit
278template <
typename Type1,
typename Type2>
281 jassert (Type1() <=
static_cast<Type1
> (upperLimit));
282 return Type1() <= valueToTest && valueToTest < static_cast<Type1> (upperLimit);
285template <
typename Type>
289 return static_cast<unsigned int> (valueToTest) <
static_cast<unsigned int> (upperLimit);
297template <
typename Type1,
typename Type2>
300 jassert (Type1() <=
static_cast<Type1
> (upperLimit));
301 return Type1() <= valueToTest && valueToTest <= static_cast<Type1> (upperLimit);
304template <
typename Type>
308 return static_cast<unsigned int> (valueToTest) <=
static_cast<unsigned int> (upperLimit);
314template <
typename Type>
317 return std::abs (
a -
b) <= tolerance;
323template <
typename Type>
326 return std::abs (
a -
b) <= (std::numeric_limits<Type>::epsilon() * std::max (
a,
b))
327 || std::abs (
a -
b) < std::numeric_limits<Type>::min();
332template <
typename... Types>
343template <
typename Type,
size_t N>
351template <
typename Type>
355 return static_cast<Type
> (_hypot (
a,
b));
357 return static_cast<Type
> (hypot (
a,
b));
366 return _hypotf (
a,
b);
368 return hypotf (
a,
b);
378template <
typename FloatType>
382 static constexpr FloatType
pi =
static_cast<FloatType
> (3.141592653589793238L);
385 static constexpr FloatType
twoPi =
static_cast<FloatType
> (2 * 3.141592653589793238L);
388 static constexpr FloatType
halfPi =
static_cast<FloatType
> (3.141592653589793238L / 2);
391 static constexpr FloatType
euler =
static_cast<FloatType
> (2.71828182845904523536L);
394 static constexpr FloatType
sqrt2 =
static_cast<FloatType
> (1.4142135623730950488L);
399[[deprecated (
"This is deprecated in favour of MathConstants<double>::pi.")]]
403[[deprecated (
"This is deprecated in favour of MathConstants<float>::pi.")]]
408template <
typename FloatType>
412template <
typename FloatType>
420template <
typename NumericType>
429 #if JUCE_WINDOWS && ! JUCE_MINGW
430 return _finite (
value) != 0;
432 return std::isfinite (
value);
439 #if JUCE_WINDOWS && ! JUCE_MINGW
440 return _finite (
value) != 0;
442 return std::isfinite (
value);
448 #pragma optimize ("t", off)
449 #ifndef __INTEL_COMPILER
450 #pragma float_control (precise, on, push)
464template <
typename FloatType>
467 #ifdef __INTEL_COMPILER
468 #pragma float_control (precise, on, push)
471 union {
int asInt[2];
double asDouble; }
n;
472 n.asDouble = ((double)
value) + 6755399441055744.0;
487 #ifndef __INTEL_COMPILER
488 #pragma float_control (pop)
490 #pragma optimize ("", on)
500 #ifdef __INTEL_COMPILER
501 #pragma float_control (pop)
514template <
typename FloatType>
519 <=
static_cast<FloatType
> (std::numeric_limits<unsigned int>::max()));
521 return static_cast<unsigned int> (
value);
526template <
typename IntegerType>
548int findHighestSetBit (
uint32 n)
noexcept;
553 n -= ((
n >> 1) & 0x55555555);
554 n = (((
n >> 2) & 0x33333333) + (
n & 0x33333333));
555 n = (((
n >> 4) +
n) & 0x0f0f0f0f);
558 return (
int) (
n & 0x3f);
570template <
typename IntegerType>
575 return (dividend < 0) ? (dividend + divisor) : dividend;
579template <
typename NumericType>
580inline constexpr NumericType
square (NumericType
n)
noexcept
593void writeLittleEndianBitsInBuffer (
void* targetBuffer,
uint32 startBit,
uint32 numBits,
uint32 value)
noexcept;
602uint32 readLittleEndianBitsInBuffer (
const void* sourceBuffer,
uint32 startBit,
uint32 numBits)
noexcept;
606#if JUCE_INTEL || DOXYGEN
611 #define JUCE_UNDENORMALISE(x) { (x) += 0.1f; (x) -= 0.1f; }
613 #define JUCE_UNDENORMALISE(x)
682 [[deprecated (
"Use std::abs() instead.")]]
inline int64 abs64 (
int64 n)
noexcept {
return std::abs (
n); }
Type jmin(const Type a, const Type b)
Definition MathsFunctions.h:60
Type jmax(const Type a, const Type b)
Definition MathsFunctions.h:48
#define noexcept
Definition DistrhoDefines.h:72
uint8_t a
Definition Spc_Cpu.h:141
int64_t int64
Definition basics.h:91
uint64_t uint64
Definition basics.h:92
uint32_t uint32
Definition basics.h:90
int roundToIntAccurate(double value) noexcept
Definition MathsFunctions.h:368
unsigned v[N_MAX]
Definition inflate.c:1584
unsigned d
Definition inflate.c:940
static PuglViewHint int value
Definition pugl.h:1708
JSAMPIMAGE data
Definition jpeglib.h:945
Definition juce_MathsFunctions.h:620
Definition carla_juce.cpp:31
bool isWithin(Type a, Type b, Type tolerance) noexcept
Definition juce_MathsFunctions.h:315
Type mapToLog10(Type value0To1, Type logRangeMin, Type logRangeMax)
Definition juce_MathsFunctions.h:144
unsigned short uint16
Definition juce_MathsFunctions.h:41
unsigned long long uint64
Definition juce_MathsFunctions.h:56
const constexpr float float_Pi
Definition juce_MathsFunctions.h:404
constexpr Type jmap(Type value0To1, Type targetRangeMin, Type targetRangeMax)
Definition juce_MathsFunctions.h:120
constexpr Type jmin(Type a, Type b)
Definition juce_MathsFunctions.h:106
void findMinAndMax(const Type *values, int numValues, Type &lowest, Type &highest)
Definition juce_MathsFunctions.h:219
bool approximatelyEqual(Type a, Type b) noexcept
Definition juce_MathsFunctions.h:324
unsigned int uint32
Definition juce_MathsFunctions.h:45
constexpr Type jmax(Type a, Type b)
Definition juce_MathsFunctions.h:94
signed short int16
Definition juce_MathsFunctions.h:39
bool juce_isfinite(NumericType) noexcept
Definition juce_MathsFunctions.h:421
Type jlimit(Type lowerLimit, Type upperLimit, Type valueToConstrain) noexcept
Definition juce_MathsFunctions.h:262
int nextPowerOfTwo(int n) noexcept
Definition juce_MathsFunctions.h:533
long long int64
Definition juce_MathsFunctions.h:54
constexpr NumericType square(NumericType n) noexcept
Definition juce_MathsFunctions.h:580
void ignoreUnused(Types &&...) noexcept
Definition juce_MathsFunctions.h:333
signed char int8
Definition juce_MathsFunctions.h:35
int countNumberOfBits(uint32 n) noexcept
Definition juce_MathsFunctions.h:551
Type findMaximum(const Type *values, Size numValues)
Definition juce_MathsFunctions.h:199
Type juce_hypot(Type a, Type b) noexcept
Definition juce_MathsFunctions.h:352
constexpr FloatType radiansToDegrees(FloatType radians) noexcept
Definition juce_MathsFunctions.h:413
const constexpr double double_Pi
Definition juce_MathsFunctions.h:400
signed int int32
Definition juce_MathsFunctions.h:43
bool isPositiveAndNotGreaterThan(Type1 valueToTest, Type2 upperLimit) noexcept
Definition juce_MathsFunctions.h:298
bool isPositiveAndBelow(Type1 valueToTest, Type2 upperLimit) noexcept
Definition juce_MathsFunctions.h:279
constexpr bool isPowerOfTwo(IntegerType value)
Definition juce_MathsFunctions.h:527
int pointer_sized_int
Definition juce_MathsFunctions.h:80
constexpr FloatType degreesToRadians(FloatType degrees) noexcept
Definition juce_MathsFunctions.h:409
unsigned int truncatePositiveToUnsignedInt(FloatType value) noexcept
Definition juce_MathsFunctions.h:515
unsigned int pointer_sized_uint
Definition juce_MathsFunctions.h:82
IntegerType negativeAwareModulo(IntegerType dividend, const IntegerType divisor) noexcept
Definition juce_MathsFunctions.h:571
Type findMinimum(const Type *data, Size numValues)
Definition juce_MathsFunctions.h:179
unsigned char uint8
Definition juce_MathsFunctions.h:37
int roundFloatToInt(float value) noexcept
Definition juce_MathsFunctions.h:681
int roundToInt(const FloatType value) noexcept
Definition juce_MathsFunctions.h:465
constexpr int numElementsInArray(Type(&)[N]) noexcept
Definition juce_MathsFunctions.h:344
int64 abs64(int64 n) noexcept
Definition juce_MathsFunctions.h:682
Type mapFromLog10(Type valueInLogRange, Type logRangeMin, Type logRangeMax)
Definition juce_MathsFunctions.h:166
int roundDoubleToInt(double value) noexcept
Definition juce_MathsFunctions.h:680
#define N
Definition nseel-cfunc.c:36
Definition juce_MathsFunctions.h:380
static constexpr FloatType halfPi
Definition juce_MathsFunctions.h:388
static constexpr FloatType twoPi
Definition juce_MathsFunctions.h:385
static constexpr FloatType sqrt2
Definition juce_MathsFunctions.h:394
static constexpr FloatType pi
Definition juce_MathsFunctions.h:382
static constexpr FloatType euler
Definition juce_MathsFunctions.h:391
Type * type
Definition juce_MathsFunctions.h:636
Type & type
Definition juce_MathsFunctions.h:635
bool type
Definition juce_MathsFunctions.h:647
char type
Definition juce_MathsFunctions.h:637
double type
Definition juce_MathsFunctions.h:649
float type
Definition juce_MathsFunctions.h:648
int64 type
Definition juce_MathsFunctions.h:645
int type
Definition juce_MathsFunctions.h:641
long type
Definition juce_MathsFunctions.h:643
short type
Definition juce_MathsFunctions.h:639
uint64 type
Definition juce_MathsFunctions.h:646
unsigned char type
Definition juce_MathsFunctions.h:638
unsigned int type
Definition juce_MathsFunctions.h:642
unsigned long type
Definition juce_MathsFunctions.h:644
unsigned short type
Definition juce_MathsFunctions.h:640
Definition juce_MathsFunctions.h:632
const Type & type
Definition juce_MathsFunctions.h:632
double type
Definition juce_MathsFunctions.h:660
Definition juce_MathsFunctions.h:657
float type
Definition juce_MathsFunctions.h:657
uint8 type
Definition juce_MathsFunctions.h:671
uint16 type
Definition juce_MathsFunctions.h:672
uint32 type
Definition juce_MathsFunctions.h:673
uint64 type
Definition juce_MathsFunctions.h:674
Definition juce_MathsFunctions.h:668
int n
Definition crypt.c:458
return c
Definition crypt.c:175
int result
Definition process.c:1455
typedef int(UZ_EXP MsgFn)()