Portability of truncation of cast: (int)myFloat

I have some functions that depend on the truncation as opposed to rounding when casting a float to an int. is this portable behavior, or bad practice?

Does any c++ implementation round instead of truncate, or is it written in the standard somewhere?
It's in the standard.

An rvalue of a floating point type can be converted to an rvalue of an integer type. The conversion truncates; that is, the fractional part is discarded.
Last edited on
Topic archived. No new replies allowed.