Added draft readflonum.
authorTim Vaughan <tgvaughan@gmail.com>
Mon, 14 Nov 2016 01:32:46 +0000 (14:32 +1300)
committerTim Vaughan <tgvaughan@gmail.com>
Mon, 14 Nov 2016 01:32:46 +0000 (14:32 +1300)
src/float.4th
src/scheme.4th

index bdedd92..c256da9 100644 (file)
@@ -79,3 +79,18 @@ END-CODE
 CODE i->f
     pushPS(reinterpret(Int64, Float64(popPS())))
 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
+;
index c1d42e8..c448b02 100644 (file)
@@ -853,7 +853,7 @@ parse-idx-stack parse-idx-sp !
 : string? ( -- bool )
     nextchar [char] " = ;
 
 : string? ( -- bool )
     nextchar [char] " = ;
 
-: readfixnum ( -- num-atom )
+: readfixnum ( -- fixnum )
     plus? minus? or if
         minus?
         inc-parse-idx
     plus? minus? or if
         minus?
         inc-parse-idx
@@ -873,6 +873,26 @@ parse-idx-stack parse-idx-sp !
     fixnum-type
 ;
 
     fixnum-type
 ;
 
+: readflonum ( -- flonum )
+    \ DRAFT!!!
+    readfixnum drop i->f
+
+    [char] . netchar = if
+        10 i->f
+        begin digit? while
+            nextchar [char] 0 - i->f over f/ f+
+            inc-parse-idx
+        repeat
+    then
+
+    [char] e nextchar = [char] E nextchar = or if
+        readfixnum drop i->f
+        f^
+    then
+
+    flonum-type
+;
+
 : readbool ( -- bool-obj )
     inc-parse-idx
     
 : readbool ( -- bool-obj )
     inc-parse-idx