Floor and Ceil
Summary
We define floor
, ceil
, and nat_ceil
functions on linear ordered rings.
Main Definitions
floor_ring
is a linear ordered ring with floor function.floor x
is the greatest integerz
such thatz ≤ x
.fract x
is the fractional part of x, that isx - floor x
.ceil x
is the smallest integerz
such thatx ≤ z
.nat_ceil x
is the smallest nonnegative integern
withx ≤ n
.
Notations
Tags
rounding
@[class]
A floor_ring
is a linear ordered ring over α
with a function
floor : α → ℤ
satisfying ∀ (z : ℤ) (x : α), z ≤ floor x ↔ (z : α) ≤ x)
.
Instances
@[instance]
floor x
is the greatest integer z
such that z ≤ x
Equations
@[simp]
@[simp]
theorem
abs_sub_lt_one_of_floor_eq_floor
{α : Type u_1}
[decidable_linear_ordered_comm_ring α]
[floor_ring α]
{x y : α} :
The fractional part fract r of r is just r - ⌊r⌋
@[simp]
@[simp]
@[simp]
@[simp]
@[simp]
@[simp]
@[simp]
@[simp]
@[simp]
@[simp]
@[simp]
theorem
nat_ceil_add_nat
{α : Type u_1}
[linear_ordered_ring α]
[floor_ring α]
{a : α}
(a_nonneg : 0 ≤ a)
(n : ℕ) :