Skip to content

Incorrect wording in Part 2, section 1. Exercise on typecasting: int() type conversion described as flooring #68

Description

@pantomathdev

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions