Implementation of floating-point numbers (experimental). #
Equations
- Int.shift2 a b (Int.ofNat e) = (a <<< e, b)
- Int.shift2 a b (Int.negSucc e) = (a, b <<< e.succ)
Instances For
Equations
- FP.instInhabitedRMode = { default := FP.RMode.NE }
Equations
- FP.decValidFinite e m = id inferInstance
- inf [C : FP.FloatCfg] : Bool → FP.Float
- nan [C : FP.FloatCfg] : FP.Float
- finite [C : FP.FloatCfg] : Bool → (e : ℤ) → (m : ℕ) → FP.ValidFinite e m → FP.Float
Instances For
Equations
- (FP.Float.finite a e m a_1).isFinite = true
- x✝.isFinite = false
Instances For
Equations
- FP.toRat (FP.Float.finite s e m a) x_2 = match Int.shift2 m 1 e with | (n, d) => let r := mkRat (↑n) d; if s = true then -r else r
Instances For
Equations
- FP.Float.zero s = FP.Float.finite s FP.emin 0 ⋯
Instances For
Equations
- FP.instInhabitedFloat = { default := FP.Float.zero true }
Equations
- (FP.Float.inf s).sign' = pure s
- FP.Float.nan.sign' = ⊤
- (FP.Float.finite s e m a).sign' = pure s
Instances For
Equations
- (FP.Float.inf s).sign = s
- FP.Float.nan.sign = false
- (FP.Float.finite s e m a).sign = s
Instances For
Equations
- (FP.Float.finite a e 0 a_1).isZero = true
- x✝.isZero = false
Instances For
Equations
- (FP.Float.inf s).neg = FP.Float.inf !s
- FP.Float.nan.neg = FP.Float.nan
- (FP.Float.finite s e m a).neg = FP.Float.finite (!s) e m a
Instances For
Equations
- FP.divNatLtTwoPow n d (Int.ofNat e) = decide (n < d <<< e)
- FP.divNatLtTwoPow n d (Int.negSucc e) = decide (n <<< e.succ < d)
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- FP.nextUpPos e m v = if ss : m.succ.size = m.size then FP.Float.finite false e m.succ ⋯ else if h : e = ↑FP.emax then FP.Float.inf false else FP.Float.finite false e.succ m.succ.div2 ⋯
Instances For
Equations
- One or more equations did not get rendered due to their size.
- FP.nextDnPos e 0 v_2 = FP.nextUpPos FP.emin 0 ⋯
Instances For
Equations
- FP.nextUp (FP.Float.finite false e m f) = FP.nextUpPos e m f
- FP.nextUp (FP.Float.finite true e m f) = (FP.nextDnPos e m f).neg
- FP.nextUp x✝ = x✝
Instances For
Equations
- FP.nextDn (FP.Float.finite false e m f) = FP.nextDnPos e m f
- FP.nextDn (FP.Float.finite true e m f) = (FP.nextUpPos e m f).neg
- FP.nextDn x✝ = x✝
Instances For
Equations
- FP.ofRatUp { num := 0, den := den, den_nz := den_nz, reduced := reduced } = FP.Float.zero false
- FP.ofRatUp { num := Int.ofNat n.succ, den := d, den_nz := h, reduced := reduced } = match FP.ofPosRatDn n.succPNat ⟨d, ⋯⟩ with | (f, exact) => if exact = true then f else FP.nextUp f
- FP.ofRatUp { num := Int.negSucc n, den := d, den_nz := h, reduced := reduced } = (FP.ofPosRatDn n.succPNat ⟨d, ⋯⟩).1.neg
Instances For
Equations
- FP.ofRatDn r = (FP.ofRatUp (-r)).neg
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- FP.Float.instNeg = { neg := FP.Float.neg }
Equations
- FP.Float.add mode FP.Float.nan x✝ = FP.Float.nan
- FP.Float.add mode x✝ FP.Float.nan = FP.Float.nan
- FP.Float.add mode (FP.Float.inf true) (FP.Float.inf false) = FP.Float.nan
- FP.Float.add mode (FP.Float.inf false) (FP.Float.inf true) = FP.Float.nan
- FP.Float.add mode (FP.Float.inf s₁) x✝ = FP.Float.inf s₁
- FP.Float.add mode x✝ (FP.Float.inf s₂) = FP.Float.inf s₂
- FP.Float.add mode (FP.Float.finite s₁ e₁ m₁ v₁) (FP.Float.finite s₂ e₂ m₂ v₂) = FP.ofRat mode (FP.toRat (FP.Float.finite s₁ e₁ m₁ v₁) ⋯ + FP.toRat (FP.Float.finite s₂ e₂ m₂ v₂) ⋯)
Instances For
Equations
- FP.Float.instAdd = { add := FP.Float.add FP.RMode.NE }
Equations
- FP.Float.sub mode f1 f2 = FP.Float.add mode f1 (-f2)
Instances For
Equations
- FP.Float.instSub = { sub := FP.Float.sub FP.RMode.NE }
Equations
- FP.Float.mul mode FP.Float.nan x✝ = FP.Float.nan
- FP.Float.mul mode x✝ FP.Float.nan = FP.Float.nan
- FP.Float.mul mode (FP.Float.inf s₁) x✝ = if x✝.isZero = true then FP.Float.nan else FP.Float.inf (s₁ ^^ x✝.sign)
- FP.Float.mul mode x✝ (FP.Float.inf s₂) = if x✝.isZero = true then FP.Float.nan else FP.Float.inf (x✝.sign ^^ s₂)
- FP.Float.mul mode (FP.Float.finite s₁ e₁ m₁ v₁) (FP.Float.finite s₂ e₂ m₂ v₂) = FP.ofRat mode (FP.toRat (FP.Float.finite s₁ e₁ m₁ v₁) ⋯ * FP.toRat (FP.Float.finite s₂ e₂ m₂ v₂) ⋯)
Instances For
Equations
- One or more equations did not get rendered due to their size.
- FP.Float.div mode FP.Float.nan x✝ = FP.Float.nan
- FP.Float.div mode x✝ FP.Float.nan = FP.Float.nan
- FP.Float.div mode (FP.Float.inf a) (FP.Float.inf a_1) = FP.Float.nan
- FP.Float.div mode (FP.Float.inf s₁) x✝ = FP.Float.inf (s₁ ^^ x✝.sign)
- FP.Float.div mode x (FP.Float.inf s₂) = FP.Float.zero (x.sign ^^ s₂)