RationalFloor

com.phasmidsoftware.number.core.inner.RationalFloor
object RationalFloor

Extension methods for Rational to support floor and ceiling operations.

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any
Self type

Members list

Extensions

Extensions

extension (r: Rational)

Computes the ceiling of this Rational number. The ceiling is the smallest integer (as a Rational) that is greater than or equal to this number.

Computes the ceiling of this Rational number. The ceiling is the smallest integer (as a Rational) that is greater than or equal to this number.

Examples:

  • Rational(7, 2).ceiling = Rational(4) // 3.5 -> 4
  • Rational(-7, 2).ceiling = Rational(-3) // -3.5 -> -3
  • Rational(6, 2).ceiling = Rational(3) // 3.0 -> 3

Attributes

Returns

the ceiling of this Rational as a Rational

Computes the floor of this Rational number. The floor is the largest integer (as a Rational) that is less than or equal to this number.

Computes the floor of this Rational number. The floor is the largest integer (as a Rational) that is less than or equal to this number.

Examples:

  • Rational(7, 2).floor = Rational(3) // 3.5 -> 3
  • Rational(-7, 2).floor = Rational(-4) // -3.5 -> -4
  • Rational(6, 2).floor = Rational(3) // 3.0 -> 3

Attributes

Returns

the floor of this Rational as a Rational