| 1 |
------------------------------------------------------------------------ |
| 2 |
-- The Agda standard library |
| 3 |
-- |
| 4 |
-- Floats: basic types and operations |
| 5 |
------------------------------------------------------------------------ |
| 6 |
|
| 7 |
{-# OPTIONS --cubical-compatible --safe #-} |
| 8 |
|
| 9 |
module Data.Float.Base where |
| 10 |
|
| 11 |
open import Data.Bool.Base using (T) |
| 12 |
import Data.Word64.Base as Word64 using (Word64; toℕ) |
| 13 |
import Data.Maybe.Base as Maybe using (Maybe; map) |
| 14 |
open import Function.Base using (_on_; _∘_) |
| 15 |
open import Agda.Builtin.Equality using (_≡_) |
| 16 |
open import Relation.Binary.Core using (Rel) |
| 17 |
|
| 18 |
------------------------------------------------------------------------ |
| 19 |
-- Re-export built-ins publically |
| 20 |
|
| 21 |
open import Agda.Builtin.Float public |
| 22 |
using (Float) |
| 23 |
renaming |
| 24 |
-- Relations |
| 25 |
( primFloatInequality to infix 4 _≤ᵇ_ |
| 26 |
; primFloatEquality to infix 4 _≡ᵇ_ |
| 27 |
; primFloatLess to infix 4 _<ᵇ_ |
| 28 |
; primFloatIsInfinite to isInfinite |
| 29 |
; primFloatIsNaN to isNaN |
| 30 |
; primFloatIsNegativeZero to isNegativeZero |
| 31 |
; primFloatIsSafeInteger to isSafeInteger |
| 32 |
-- Conversions |
| 33 |
; primFloatToWord64 to toWord64 |
| 34 |
; primNatToFloat to fromℕ |
| 35 |
; primIntToFloat to fromℤ |
| 36 |
; primFloatRound to round |
| 37 |
; primFloatFloor to ⌊_⌋ |
| 38 |
; primFloatCeiling to ⌈_⌉ |
| 39 |
; primFloatToRatio to toRatio |
| 40 |
; primRatioToFloat to fromRatio |
| 41 |
; primFloatDecode to decode |
| 42 |
; primFloatEncode to encode |
| 43 |
; primShowFloat to show |
| 44 |
-- Operations |
| 45 |
; primFloatPlus to infixl 6 _+_ |
| 46 |
; primFloatMinus to infixl 6 _-_ |
| 47 |
; primFloatTimes to infixl 7 _*_ |
| 48 |
; primFloatDiv to infixl 7 _÷_ |
| 49 |
; primFloatPow to infixl 8 _**_ |
| 50 |
; primFloatNegate to infixr 9 -_ |
| 51 |
; primFloatSqrt to sqrt |
| 52 |
; primFloatExp to infixr 9 e^_ |
| 53 |
; primFloatLog to log |
| 54 |
; primFloatSin to sin |
| 55 |
; primFloatCos to cos |
| 56 |
; primFloatTan to tan |
| 57 |
; primFloatASin to asin |
| 58 |
; primFloatACos to acos |
| 59 |
; primFloatATan to atan |
| 60 |
; primFloatATan2 to atan2 |
| 61 |
; primFloatSinh to sinh |
| 62 |
; primFloatCosh to cosh |
| 63 |
; primFloatTanh to tanh |
| 64 |
; primFloatASinh to asinh |
| 65 |
; primFloatACosh to acosh |
| 66 |
; primFloatATanh to atanh |
| 67 |
) |
| 68 |
|
| 69 |
infix 4 _≈_ |
| 70 |
|
| 71 |
_≈_ : Rel Float _ |
| 72 |
_≈_ = _≡_ on Maybe.map Word64.toℕ ∘ toWord64 |
| 73 |
|
| 74 |
|
| 75 |
infix 4 _≤_ |
| 76 |
_≤_ : Rel Float _ |
| 77 |
x ≤ y = T (x ≤ᵇ y) |
| 78 |
|
| 79 |
|
| 80 |
------------------------------------------------------------------------ |
| 81 |
-- DEPRECATIONS |
| 82 |
|
| 83 |
toWord = toWord64 |
| 84 |
{-# WARNING_ON_USAGE toWord |
| 85 |
"Warning: toWord was deprecated in v2.1. |
| 86 |
Please use toWord64 instead." |
| 87 |
#-} |