Use integer math

Since 'data' is an integer value clipped between +/-8192 and 'nrpn_scale' is a char value, this calculation could be done with integers and then return the fluid_real_t value.

Addresses #455.
This commit is contained in:
carlo-bramini 2018-11-01 11:51:04 +01:00 committed by derselbst
parent a948f7c5b2
commit 2205e4a8fc

View file

@ -150,7 +150,7 @@ fluid_real_t fluid_gen_scale(int gen, float value)
fluid_real_t fluid_gen_scale_nrpn(int gen, int data)
{
fluid_real_t value = (float) data - 8192.0f;
fluid_clip(value, -8192, 8192);
return value * (float) fluid_gen_info[gen].nrpn_scale;
data = data - 8192;
fluid_clip(data, -8192, 8192);
return (fluid_real_t)(data * fluid_gen_info[gen].nrpn_scale);
}