Added draft readflonum.
[scheme.forth.jl.git] / src / float.4th
index 95aaa3b..c256da9 100644 (file)
@@ -30,15 +30,67 @@ CODE f/
     pushPS(reinterpret(Int64, a/b))
 END-CODE
 
-( addr len -- float )
-CODE float-parse
-    len = popPS()
-    addr = popPS()
-    val = parse(Float64, getString(addr, len))
-    pushPS(reinterpret(Int64, val))
-END-CODE
-
-( float -- )
-CODE float-print
-    print(reinterpret(Float64, popPS()))
-END-CODE
\ No newline at end of file
+CODE f^
+    b = reinterpret(Float64, popPS())
+    a = reinterpret(Float64, popPS())
+    pushPS(reinterpret(Int64, a^b))
+END-CODE
+
+CODE f>
+    b = reinterpret(Float64, popPS())
+    a = reinterpret(Float64, popPS())
+    pushPS(reinterpret(Int64, a>b))
+END-CODE
+
+CODE f<
+    b = reinterpret(Float64, popPS())
+    a = reinterpret(Float64, popPS())
+    pushPS(reinterpret(Int64, a<b))
+END-CODE
+
+CODE f=
+    b = reinterpret(Float64, popPS())
+    a = reinterpret(Float64, popPS())
+    pushPS(reinterpret(Int64, a=b))
+END-CODE
+
+CODE f<=
+    b = reinterpret(Float64, popPS())
+    a = reinterpret(Float64, popPS())
+    pushPS(reinterpret(Int64, a<=b))
+END-CODE
+
+CODE f>=
+    b = reinterpret(Float64, popPS())
+    a = reinterpret(Float64, popPS())
+    pushPS(reinterpret(Int64, a>=b))
+END-CODE
+
+CODE flog
+    b = reinterpret(Float64, popPS())
+    pushPS(reinterpret(Int64, log(a)))
+END-CODE
+
+CODE fexp
+    b = reinterpret(Float64, popPS())
+    pushPS(reinterpret(Int64, exp(a)))
+END-CODE
+
+CODE i->f
+    pushPS(reinterpret(Int64, Float64(popPS())))
+END-CODE
+
+: f.scientific ( float -- )
+;
+
+: f.plain ( float -- )
+
+;
+
+: f. ( float -- )
+    dup dup 1000000 i->f f>= swap 1 i->f 10000 i->f f/ f< or if
+        f.scientific
+    else
+        f.plain
+    then
+;