Rational

scalus.cardano.onchain.plutus.prelude.Rational
See theRational companion class
object Rational

Attributes

Companion
class
Graph
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
Rational.type

Members list

Type members

Inherited and Abstract types

type MirroredElemLabels <: Tuple

The names of the product elements

The names of the product elements

Attributes

Inherited from:
Mirror
type MirroredLabel <: String

The name of the type

The name of the type

Attributes

Inherited from:
Mirror

Value members

Concrete fields

lazy val sirDeps: List[SIRModuleWithDeps]
lazy val sirModule: Module

Givens

Givens

inline given rationalNoEq: Eq[Rational]

Rational intentionally has no usable Eq: its mathematical equality is cross-multiplication (a/b == c/d iff a*d == c*b), which is non-structural and cannot be expressed by the structural-equality lowering. This given only produces a clear compile error if someone writes r1 === r2 / r1 == r2, or Eq.derived for a type with a Rational field. Use RationalEq.equals for value equality, or normalize for a reduced (lowest-terms) form that can be compared structurally.

Rational intentionally has no usable Eq: its mathematical equality is cross-multiplication (a/b == c/d iff a*d == c*b), which is non-structural and cannot be expressed by the structural-equality lowering. This given only produces a clear compile error if someone writes r1 === r2 / r1 == r2, or Eq.derived for a type with a Rational field. Use RationalEq.equals for value equality, or normalize for a reduced (lowest-terms) form that can be compared structurally.

Attributes

Extensions

Extensions

extension (self: Rational)
inline def checkDenominator(): Unit
def isZero: Boolean

Reduce to lowest terms, with the sign carried on the numerator (denominator made positive). After normalization two equal-valued rationals share identical numerator/denominator, so they may be compared structurally.

Reduce to lowest terms, with the sign carried on the numerator (denominator made positive). After normalization two equal-valued rationals share identical numerator/denominator, so they may be compared structurally.

Attributes