Hello George
Replying to a message of George White to Neil Heller:
NH>> result1 = longint1 * longint2 * multiplier; /* 37 */
GW> Fine, the float result is 37.07384 before the cast back to long.
NH>> result2 = longint1 * longint2 * multiplier + 0.9999F; /* 38 */
GW> Again fine, as the float result is 38.07375 before the cast back to
GW> long.
GW> According to the rules the two longs should be promoted to float
GW> before the calculation, the calculation made and then the result cast
GW> back to long (which discards any fractional part).
Aren't the two longs multiplied first before the result is promoted?
Promoted to what? The two manuals I've got disagree. Mix Power C says
floats are promoted to double. Turbo C manual says that float stays float.
Alan
"Computers do bite"
--- FleetStreet 1.14 NR
---------------
* Origin: Alan's Point on Donor/2 (2:440/4.6)
|