juce_core/maths/juce_MathsFunctions.h
inline int floatToUInt(float x) { unsigned int e = (0x7F + 31) - ((* (unsigned int*) &x & 0x7F800000) >> 23); unsigned int m = 0x80000000 | (* (unsigned int*) &x << 8); return int((m >> e) & -(e < 32)); } inline int roundToIntFloat(float x) { // round if (x >= 0) return floatToUInt(x + 0.5f); return -floatToUInt(0.5f - x); } // specialise template <> inline int roundToInt<float>(const float value) noexcept { return roundToIntFloat(value); }
Been trying it in my builds, mainly to avoid unnecessary use of double.