Rounding Up and Down

Description

To round a value $x$ to the nearest integer in Sage, we use the floor(x) or ceil(x) depending on if we want to round down or up.

Sage Cell

Rounding down

Code

x = sqrt(10)
floor(x)

Rounding up

Code

x = sqrt(10)
ceil(x)

Options

none

Tags

Primary Tags—Programming:The Python language.

Secondary Tags—The Python language: Numeric operations.

Related Cells

Attribute

Permalink:

Author:

Date: 06 Mar 2019 00:28

Submitted by: Zane Corbiere

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License