In the Part 2, section 1. "Programming Terminology" of the material, in the Typecasting programming exercise, the following has been quoted:
Notice the function always rounds down, and not according to the rounding rules in mathematics. This is an example of a floor function.
Which is incorrect, since the int() function in question truncates towards zero, whereas math.floor() returns the greatest integer less than or equal to the input.
It may be clearer to describe mathematically, that int() here as "removing the fractional part" or "truncating towards zero".
For example:
int(-5.15) # -5
math.floor(-5.15) # -6
In the Part 2, section 1. "Programming Terminology" of the material, in the Typecasting programming exercise, the following has been quoted:
Which is incorrect, since the
int()function in question truncates towards zero, whereas math.floor() returns the greatest integer less than or equal to the input.It may be clearer to describe mathematically, that
int()here as "removing the fractional part" or "truncating towards zero".For example: