aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/lux/data/number.lux
diff options
context:
space:
mode:
Diffstat (limited to 'stdlib/source/lux/data/number.lux')
-rw-r--r--stdlib/source/lux/data/number.lux13
1 files changed, 11 insertions, 2 deletions
diff --git a/stdlib/source/lux/data/number.lux b/stdlib/source/lux/data/number.lux
index 8c3d08dbf..046e681b8 100644
--- a/stdlib/source/lux/data/number.lux
+++ b/stdlib/source/lux/data/number.lux
@@ -109,7 +109,8 @@
[ Nat (_lux_proc ["nat" "max-value"] []) (_lux_proc ["nat" "min-value"] [])]
[ Int (_lux_proc ["jvm" "getstatic:java.lang.Long:MAX_VALUE"] []) (_lux_proc ["jvm" "getstatic:java.lang.Long:MIN_VALUE"] [])]
- [Real (_lux_proc ["jvm" "getstatic:java.lang.Double:MAX_VALUE"] []) (_lux_proc ["jvm" "getstatic:java.lang.Double:MIN_VALUE"] [])])
+ [Real (_lux_proc ["jvm" "getstatic:java.lang.Double:MAX_VALUE"] []) (_lux_proc ["jvm" "getstatic:java.lang.Double:MIN_VALUE"] [])]
+ [Frac (_lux_proc ["frac" "max-value"] []) (_lux_proc ["frac" "max-value"] [])])
(do-template [<name> <type> <unit> <append>]
[(struct: #export <name> (Monoid <type>)
@@ -128,6 +129,10 @@
[Mul@Monoid<Real> Real 1.0 r.*]
[Max@Monoid<Real> Real (:: Bounded<Real> bottom) r.max]
[Min@Monoid<Real> Real (:: Bounded<Real> top) r.min]
+ [Add@Monoid<Frac> Frac (:: Bounded<Frac> bottom) f.+]
+ [Mul@Monoid<Frac> Frac (:: Bounded<Frac> top) f.*]
+ [Max@Monoid<Frac> Frac (:: Bounded<Frac> bottom) f.max]
+ [Min@Monoid<Frac> Frac (:: Bounded<Frac> top) f.min]
)
(def: (text.replace pattern value template)
@@ -197,7 +202,7 @@
(def: (decode repr)
(_lux_proc ["jvm" "try"]
- [(#;Right (int-to-nat (_lux_proc ["jvm" "invokestatic:java.lang.Long:valueOf:java.lang.String,int"] [repr (_lux_proc ["jvm" "l2i"] [<radix>])])))
+ [(#;Right (int-to-nat (_lux_proc ["jvm" "invokestatic:java.lang.Long:parseUnsignedLong:java.lang.String,int"] [repr (_lux_proc ["jvm" "l2i"] [<radix>])])))
(lambda [ex] (#;Left <error>))])))
(macro: #export (<macro> tokens state)
@@ -233,3 +238,7 @@
[+inf "getstatic:java.lang.Double:POSITIVE_INFINITY"]
[-inf "getstatic:java.lang.Double:NEGATIVE_INFINITY"]
)
+
+(def: #export (nan? number)
+ (-> Real Bool)
+ (not (r.= number number)))