Documentation

Init.Data.OfScientific

class OfScientific (α : Type u) :

For decimal and scientific numbers (e.g., 1.23, 3.12e10). Examples:

Note the use of nat_lit; there is no wrapping OfNat.ofNat in the resulting term.

  • ofScientific (mantissa : Nat) (exponentSign : Bool) (decimalExponent : Nat) : α

    Produces a value from the given mantissa, exponent sign, and decimal exponent. For the exponent sign, true indicates a negative exponent.

    Examples:

    Note the use of nat_lit; there is no wrapping OfNat.ofNat in the resulting term.

Instances

    Computes m * 2^e.

    Equations
      Instances For
        opaque Float.ofScientific (m : Nat) (s : Bool) (e : Nat) :

        Constructs a Float from the given mantissa, sign, and exponent values.

        This function is part of the implementation of the OfScientific Float instance that is used to interpret floating-point literals.

        @[defaultInstance 501]

        The OfScientific Float must have priority higher than mid since the default instance Neg Int has mid priority.

        #check -42.0 -- must be Float
        
        Equations
          @[export lean_float_of_nat]
          def Float.ofNat (n : Nat) :

          Converts a natural number into the closest-possible 64-bit floating-point number, or an infinite floating-point value if the range of Float is exceeded.

          Equations
            Instances For

              Converts an integer into the closest-possible 64-bit floating-point number, or positive or negative infinite floating-point value if the range of Float is exceeded.

              Equations
                Instances For
                  instance instOfNatFloat {n : Nat} :
                  Equations
                    @[reducible, inline]
                    abbrev Nat.toFloat (n : Nat) :

                    Converts a natural number into the closest-possible 64-bit floating-point number, or an infinite floating-point value if the range of Float is exceeded.

                    Equations
                      Instances For

                        Computes m * 2^e.

                        Equations
                          Instances For
                            opaque Float32.ofScientific (m : Nat) (s : Bool) (e : Nat) :

                            Constructs a Float32 from the given mantissa, sign, and exponent values.

                            This function is part of the implementation of the OfScientific Float32 instance that is used to interpret floating-point literals.

                            @[export lean_float32_of_nat]

                            Converts a natural number into the closest-possible 32-bit floating-point number, or an infinite floating-point value if the range of Float32 is exceeded.

                            Equations
                              Instances For

                                Converts an integer into the closest-possible 32-bit floating-point number, or positive or negative infinite floating-point value if the range of Float32 is exceeded.

                                Equations
                                  Instances For
                                    instance instOfNatFloat32 {n : Nat} :
                                    Equations
                                      @[reducible, inline]
                                      abbrev Nat.toFloat32 (n : Nat) :

                                      Converts a natural number into the closest-possible 32-bit floating-point number, or an infinite floating-point value if the range of Float32 is exceeded.

                                      Equations
                                        Instances For