cocos2d/cocos/audio/android/audio_utils/include/audio_utils/primitives.h
static inline int32_t clamp24_from_float(float f)
{
    static const float scale = (float)(1 << 23);
    static const float limpos = 0x7fffff / (float)(1 << 23);
    static const float limneg = -0x800000 / (float)(1 << 23);

    if (f <= limneg) {
        return -0x800000;
    } else if (f >= limpos) {
        return 0x7fffff;
    }
    f *= scale;
    /* integer conversion is through truncation (though int to float is not).
     * ensure that we round to nearest, ties away from 0.
     */
    return f > 0 ? f + 0.5 : f - 0.5;
}
/* Convert a single-precision floating point value to a Q0.23 integer value, stored in a
 * 32 bit signed integer (technically stored as Q8.23, but clamped to Q0.23).
 *
 * Rounds to nearest, ties away from 0.
 *
 * Values outside the range [-1.0, 1.0) are properly clamped to -8388608 and 8388607,
 * including -Inf and +Inf. NaN values are considered undefined, and behavior may change
 * depending on hardware and future implementation of this function.
 */
Convert a single-precision floating point value to a Q0.23 integer value, stored in a
32 bit signed integer (technically stored as Q8.23, but clamped to Q0.23).

Rounds to nearest, ties away from 0.

Values outside the range [-1.0, 1.0) are properly clamped to -8388608 and 8388607,
including -Inf and +Inf. NaN values are considered undefined, and behavior may change
depending on hardware and future implementation of this function.
Convert a single - precision floating point value to a Q0 . 23 integer value stored in a 32 bit signed integer ( technically stored as Q8 . 23 but clamped to Q0 . 23 ) . Rounds to nearest ties away from 0 . Values outside the range [ - 1 . 0 1 . 0 ) are properly clamped to - 8388608 and 8388607 including - Inf and + Inf . NaN values are considered undefined and behavior may change depending on hardware and future implementation of this function .
static inline int32_t clamp24_from_float(float f)
{
    static const float scale = (float)(1 << 23);
    static const float limpos = 0x7fffff / (float)(1 << 23);
    static const float limneg = -0x800000 / (float)(1 << 23);
    if (f <= limneg) {
        return -0x800000;
    } else if (f >= limpos) {
        return 0x7fffff;
    }
    f *= scale;
    return f > 0 ? f + 0.5 : f - 0.5;
}
static inline int32_t clamp24_from_float ( float f ) { static const float scale = ( float ) ( 1 << 23 ) ; static const float limpos = 0x7fffff / ( float ) ( 1 << 23 ) ; static const float limneg = -0x800000 / ( float ) ( 1 << 23 ) ; if ( f <= limneg ) { return -0x800000 ; } else if ( f >= limpos ) { return 0x7fffff ; } f *= scale ; return f > 0 ? f + 0.5 : f - 0.5 ; }
Convert a single-precision floating point value to a Q0.23 integer value, stored in a
 32 bit signed integer (technically stored as Q8.23, but clamped to Q0.23).
Convert a single - precision floating point value to a Q0 . 23 integer value stored in a 32 bit signed integer ( technically stored as Q8 . 23 but clamped to Q0 . 23 ) .
/* integer conversion is through truncation (though int to float is not).
     * ensure that we round to nearest, ties away from 0.
     */