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) : α
Instances

Computes m * 2^e.

Equations
opaque Float.ofScientific (m : Nat) (s : Bool) (e : Nat) :
@[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) :
Equations
instance instOfNatFloat {n : Nat} :
Equations
@[reducible, inline]
abbrev Nat.toFloat (n : Nat) :
Equations

Computes m * 2^e.

Equations
opaque Float32.ofScientific (m : Nat) (s : Bool) (e : Nat) :
@[export lean_float32_of_nat]
Equations
instance instOfNatFloat32 {n : Nat} :
Equations
@[reducible, inline]
abbrev Nat.toFloat32 (n : Nat) :
Equations