Documentation

Std.Time.Internal.UnitVal

A structure representing a unit of a given ratio type α.

  • ofInt :: (
    • val : Int

      Value inside the UnitVal Value.

  • )
Instances For
    Equations
    • Std.Time.Internal.instInhabitedUnitVal = { default := { val := default } }
    Equations
    • Std.Time.Internal.instBEqUnitVal = { beq := Std.Time.Internal.beqUnitVal✝ }
    Equations
    Equations
    @[inline]

    Creates a UnitVal from a Nat.

    Equations
    Instances For
      @[inline]

      Converts a UnitVal to an Int.

      Equations
      • unit.toInt = unit.val
      Instances For
        @[inline]
        def Std.Time.Internal.UnitVal.mul {a : Std.Internal.Rat} (unit : Std.Time.Internal.UnitVal a) (factor : Int) :
        Std.Time.Internal.UnitVal (a / { num := factor, den := 1 })

        Multiplies the UnitVal by an Int, resulting in a new UnitVal with an adjusted ratio.

        Equations
        • unit.mul factor = { val := unit.val * factor }
        Instances For
          @[inline]
          def Std.Time.Internal.UnitVal.ediv {a : Std.Internal.Rat} (unit : Std.Time.Internal.UnitVal a) (divisor : Int) :
          Std.Time.Internal.UnitVal (a * { num := divisor, den := 1 })

          Divides the UnitVal by an Int, resulting in a new UnitVal with an adjusted ratio.

          Equations
          • unit.ediv divisor = { val := unit.val.ediv divisor }
          Instances For
            @[inline]
            def Std.Time.Internal.UnitVal.div {a : Std.Internal.Rat} (unit : Std.Time.Internal.UnitVal a) (divisor : Int) :
            Std.Time.Internal.UnitVal (a * { num := divisor, den := 1 })

            Divides the UnitVal by an Int, resulting in a new UnitVal with an adjusted ratio.

            Equations
            • unit.div divisor = { val := unit.val.tdiv divisor }
            Instances For
              @[inline]

              Adds two UnitVal values of the same ratio.

              Equations
              • u1.add u2 = { val := u1.val + u2.val }
              Instances For
                @[inline]

                Subtracts one UnitVal value from another of the same ratio.

                Equations
                • u1.sub u2 = { val := u1.val - u2.val }
                Instances For
                  @[inline]

                  Returns the absolute value of a UnitVal.

                  Equations
                  • u.abs = { val := u.val.natAbs }
                  Instances For
                    @[inline]

                    Converts an Offset to another unit type.

                    Equations
                    • val.convert = { val := val.toInt * (a.div b).num / (a.div b).den }
                    Instances For
                      Equations
                      • Std.Time.Internal.UnitVal.instOfNat = { ofNat := { val := Int.ofNat n } }
                      Equations
                      Equations
                      Equations
                      Equations
                      • Std.Time.Internal.UnitVal.instAdd = { add := Std.Time.Internal.UnitVal.add }
                      Equations
                      • Std.Time.Internal.UnitVal.instSub = { sub := Std.Time.Internal.UnitVal.sub }
                      Equations
                      Equations