Original Post
🔒 Locked
i
Advertisement
You''re probably passing a double to the function instead of a float. Doubles have more precision than floats, so if you truncate it to a float you may lose some precision, hence the message.
How are you calling the function? Literal floating point numbers (e.g. 10.45) are doubles unless you specify that they are floats (e.g. 10.45f).
--
Dave Mikesell Software & Consulting
How are you calling the function? Literal floating point numbers (e.g. 10.45) are doubles unless you specify that they are floats (e.g. 10.45f).
--
Dave Mikesell Software & Consulting
.01 is a double and .01f is a float. All constant decimal numbers should be followed by an ''f'' to specify that they are float. So your offending line is
subtotal = (1 - (discount * .01)) * installed_price;
change to
subtotal = (1.0f - (discount * .01f)) * installed_price;
:::: [ Triple Buffer ] ::::
subtotal = (1 - (discount * .01)) * installed_price;
change to
subtotal = (1.0f - (discount * .01f)) * installed_price;
:::: [ Triple Buffer ] ::::
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement