Rounding #
This file defines the round function, which uses the floor or ceil function to round a number
to the nearest integer.
Main Definitions #
round a: Nearest integer toa. It rounds halves towards infinity.
Tags #
rounding
Round #
@[simp]
@[simp]
@[simp]
theorem round_eq_div {α : Type u_2} [Ring α] [LinearOrder α] [FloorRing α] [IsStrictOrderedRing α] (x : α) :
Formula for round in terms of Int.floor, a version that works over any ring.
TODO: decide if we want to use this as a definition. It may be slightly faster over ℚ.
@[simp]
theorem round_add_intCast {α : Type u_2} [Ring α] [LinearOrder α] [FloorRing α] [IsStrictOrderedRing α] (x : α) (y : ℤ) :
@[simp]
theorem round_add_one {α : Type u_2} [Ring α] [LinearOrder α] [FloorRing α] [IsStrictOrderedRing α] (a : α) :
@[simp]
theorem round_sub_intCast {α : Type u_2} [Ring α] [LinearOrder α] [FloorRing α] [IsStrictOrderedRing α] (x : α) (y : ℤ) :
@[simp]
theorem round_sub_one {α : Type u_2} [Ring α] [LinearOrder α] [FloorRing α] [IsStrictOrderedRing α] (a : α) :
@[simp]
theorem round_add_natCast {α : Type u_2} [Ring α] [LinearOrder α] [FloorRing α] [IsStrictOrderedRing α] (x : α) (y : ℕ) :
@[simp]
theorem round_add_ofNat {α : Type u_2} [Ring α] [LinearOrder α] [FloorRing α] [IsStrictOrderedRing α] (x : α) (n : ℕ) [n.AtLeastTwo] :
@[simp]
theorem round_sub_natCast {α : Type u_2} [Ring α] [LinearOrder α] [FloorRing α] [IsStrictOrderedRing α] (x : α) (y : ℕ) :
@[simp]
theorem round_sub_ofNat {α : Type u_2} [Ring α] [LinearOrder α] [FloorRing α] [IsStrictOrderedRing α] (x : α) (n : ℕ) [n.AtLeastTwo] :
@[simp]
theorem round_intCast_add {α : Type u_2} [Ring α] [LinearOrder α] [FloorRing α] [IsStrictOrderedRing α] (x : α) (y : ℤ) :
@[simp]
theorem round_natCast_add {α : Type u_2} [Ring α] [LinearOrder α] [FloorRing α] [IsStrictOrderedRing α] (x : α) (y : ℕ) :
@[simp]
theorem round_ofNat_add {α : Type u_2} [Ring α] [LinearOrder α] [FloorRing α] [IsStrictOrderedRing α] (n : ℕ) [n.AtLeastTwo] (x : α) :
theorem round_eq_iff {α : Type u_2} [Field α] [LinearOrder α] [IsStrictOrderedRing α] [FloorRing α] {x : α} {n : ℤ} :
@[simp]
theorem round_two_inv {α : Type u_2} [Field α] [LinearOrder α] [IsStrictOrderedRing α] [FloorRing α] :
@[simp]
theorem round_neg_two_inv {α : Type u_2} [Field α] [LinearOrder α] [IsStrictOrderedRing α] [FloorRing α] :
@[simp]
theorem round_eq_zero_iff {α : Type u_2} [Field α] [LinearOrder α] [IsStrictOrderedRing α] [FloorRing α] {x : α} :
theorem abs_sub_round {α : Type u_2} [Field α] [LinearOrder α] [IsStrictOrderedRing α] [FloorRing α] (x : α) :
theorem sub_half_lt_round {α : Type u_2} [Field α] [LinearOrder α] [IsStrictOrderedRing α] [FloorRing α] (x : α) :
theorem round_le_add_half {α : Type u_2} [Field α] [LinearOrder α] [IsStrictOrderedRing α] [FloorRing α] (x : α) :
theorem Int.map_round {F : Type u_1} {α : Type u_2} {β : Type u_3} [Field α] [LinearOrder α] [IsStrictOrderedRing α] [Field β] [LinearOrder β] [IsStrictOrderedRing β] [FloorRing α] [FloorRing β] [FunLike F α β] [RingHomClass F α β] (f : F) (hf : StrictMono ⇑f) (a : α) :