Documentation

Init.Data.Float

structure FloatSpec :
Instances For
    structure Float :

    Native floating point type, corresponding to the IEEE 754 binary64 format (double in C or f64 in Rust).

    Instances For
      @[extern lean_float_add]
      opaque Float.add :
      FloatFloatFloat
      @[extern lean_float_sub]
      opaque Float.sub :
      FloatFloatFloat
      @[extern lean_float_mul]
      opaque Float.mul :
      FloatFloatFloat
      @[extern lean_float_div]
      opaque Float.div :
      FloatFloatFloat
      @[extern lean_float_negate]
      opaque Float.neg :
      def Float.lt :
      FloatFloatProp
      Equations
      • a.lt b = match a, b with | { val := a }, { val := b } => floatSpec.lt a b
      Instances For
        def Float.le :
        FloatFloatProp
        Equations
        Instances For
          @[extern lean_float_of_bits]

          Raw transmutation from UInt64.

          Floats and UInts have the same endianness on all supported platforms. IEEE 754 very precisely specifies the bit layout of floats.

          @[extern lean_float_to_bits]

          Raw transmutation to UInt64.

          Floats and UInts have the same endianness on all supported platforms. IEEE 754 very precisely specifies the bit layout of floats.

          Note that this function is distinct from Float.toUInt64, which attempts to preserve the numeric value, and not the bitwise value.

          Equations
          Equations
          Equations
          Equations
          Equations
          instance instLTFloat :
          Equations
          instance instLEFloat :
          Equations
          @[extern lean_float_beq]
          opaque Float.beq (a b : Float) :

          Note: this is not reflexive since NaN != NaN.

          Equations
          @[extern lean_float_decLt]
          opaque Float.decLt (a b : Float) :
          Decidable (a < b)
          @[extern lean_float_decLe]
          opaque Float.decLe (a b : Float) :
          instance floatDecLt (a b : Float) :
          Decidable (a < b)
          Equations
          instance floatDecLe (a b : Float) :
          Equations
          @[extern lean_float_to_string]
          @[extern lean_float_to_uint8]

          If the given float is non-negative, truncates the value to the nearest non-negative integer. If negative or NaN, returns 0. If larger than the maximum value for UInt8 (including Inf), returns the maximum value of UInt8 (i.e. UInt8.size - 1).

          @[extern lean_float_to_uint16]

          If the given float is non-negative, truncates the value to the nearest non-negative integer. If negative or NaN, returns 0. If larger than the maximum value for UInt16 (including Inf), returns the maximum value of UInt16 (i.e. UInt16.size - 1).

          @[extern lean_float_to_uint32]

          If the given float is non-negative, truncates the value to the nearest non-negative integer. If negative or NaN, returns 0. If larger than the maximum value for UInt32 (including Inf), returns the maximum value of UInt32 (i.e. UInt32.size - 1).

          @[extern lean_float_to_uint64]

          If the given float is non-negative, truncates the value to the nearest non-negative integer. If negative or NaN, returns 0. If larger than the maximum value for UInt64 (including Inf), returns the maximum value of UInt64 (i.e. UInt64.size - 1).

          @[extern lean_float_to_usize]

          If the given float is non-negative, truncates the value to the nearest non-negative integer. If negative or NaN, returns 0. If larger than the maximum value for USize (including Inf), returns the maximum value of USize (i.e. USize.size - 1). This value is platform dependent).

          @[extern lean_float_isnan]
          opaque Float.isNaN :
          @[extern lean_float_isfinite]
          @[extern lean_float_isinf]
          opaque Float.isInf :
          @[extern lean_float_frexp]

          Splits the given float x into a significand/exponent pair (s, i) such that x = s * 2^i where s ∈ (-1;-0.5] ∪ [0.5; 1). Returns an undefined value if x is not finite.

          @[extern lean_uint8_to_float]
          opaque UInt8.toFloat (n : UInt8) :

          Obtains the Float whose value is the same as the given UInt8.

          @[extern lean_uint16_to_float]

          Obtains the Float whose value is the same as the given UInt16.

          @[extern lean_uint32_to_float]

          Obtains the Float whose value is the same as the given UInt32.

          @[extern lean_uint64_to_float]

          Obtains a Float whose value is near the given UInt64. It will be exactly the value of the given UInt64 if such a Float exists. If no such Float exists, the returned value will either be the smallest Float this is larger than the given value, or the largest Float this is smaller than the given value.

          @[extern lean_usize_to_float]
          opaque USize.toFloat (n : USize) :

          Obtains a Float whose value is near the given USize. It will be exactly the value of the given USize if such a Float exists. If no such Float exists, the returned value will either be the smallest Float this is larger than the given value, or the largest Float this is smaller than the given value.

          @[extern sin]
          opaque Float.sin :
          @[extern cos]
          opaque Float.cos :
          @[extern tan]
          opaque Float.tan :
          @[extern asin]
          opaque Float.asin :
          @[extern acos]
          opaque Float.acos :
          @[extern atan]
          opaque Float.atan :
          @[extern atan2]
          opaque Float.atan2 :
          FloatFloatFloat
          @[extern sinh]
          opaque Float.sinh :
          @[extern cosh]
          opaque Float.cosh :
          @[extern tanh]
          opaque Float.tanh :
          @[extern asinh]
          opaque Float.asinh :
          @[extern acosh]
          opaque Float.acosh :
          @[extern atanh]
          opaque Float.atanh :
          @[extern exp]
          opaque Float.exp :
          @[extern exp2]
          opaque Float.exp2 :
          @[extern log]
          opaque Float.log :
          @[extern log2]
          opaque Float.log2 :
          @[extern log10]
          opaque Float.log10 :
          @[extern pow]
          opaque Float.pow :
          FloatFloatFloat
          @[extern sqrt]
          opaque Float.sqrt :
          @[extern cbrt]
          opaque Float.cbrt :
          @[extern ceil]
          opaque Float.ceil :
          @[extern floor]
          opaque Float.floor :
          @[extern round]
          opaque Float.round :
          @[extern fabs]
          opaque Float.abs :
          @[extern lean_float_scaleb]
          opaque Float.scaleB (x : Float) (i : Int) :

          Efficiently computes x * 2^i.