The Lambda Lab
/
projects
/
scheme.forth.jl.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Completed flonum primitives.
[scheme.forth.jl.git]
/
src
/
float.4th
diff --git
a/src/float.4th
b/src/float.4th
index
e100b46
..
51ba158
100644
(file)
--- a/
src/float.4th
+++ b/
src/float.4th
@@
-21,19
+21,19
@@
END-CODE
CODE f*
b = reinterpret(Float64, popPS())
a = reinterpret(Float64, popPS())
CODE f*
b = reinterpret(Float64, popPS())
a = reinterpret(Float64, popPS())
- pushPS(reinterpret(Int64, a*b))
+ pushPS(reinterpret(Int64, a*b
+ 0.0
))
END-CODE
CODE f/
b = reinterpret(Float64, popPS())
a = reinterpret(Float64, popPS())
END-CODE
CODE f/
b = reinterpret(Float64, popPS())
a = reinterpret(Float64, popPS())
- pushPS(reinterpret(Int64, a/b))
+ pushPS(reinterpret(Int64, a/b
+ 0.0
))
END-CODE
CODE f^
b = reinterpret(Float64, popPS())
a = reinterpret(Float64, popPS())
END-CODE
CODE f^
b = reinterpret(Float64, popPS())
a = reinterpret(Float64, popPS())
- pushPS(reinterpret(Int64, a^b))
+ pushPS(reinterpret(Int64, a^b
+ 0.0
))
END-CODE
CODE fsqrt
END-CODE
CODE fsqrt
@@
-80,7
+80,7
@@
END-CODE
CODE fmod
b = reinterpret(Float64, popPS())
a = reinterpret(Float64, popPS())
CODE fmod
b = reinterpret(Float64, popPS())
a = reinterpret(Float64, popPS())
- pushPS(reinterpret(Int64, a%b))
+ pushPS(reinterpret(Int64, a%b
+ 0.0
))
END-CODE
CODE flog
END-CODE
CODE flog
@@
-145,6
+145,11
@@
CODE fabs
pushPS(reinterpret(Int64, abs(a)))
END-CODE
pushPS(reinterpret(Int64, abs(a)))
END-CODE
+CODE fround
+ a = reinterpret(Float64, popPS())
+ pushPS(reinterpret(Int64, round(a)))
+END-CODE
+
: f/mod
2dup fmod -rot f/ ;
: f/mod
2dup fmod -rot f/ ;
@@
-163,9
+168,12
@@
END-CODE
: flog10
flog [ 10 i->f flog ] literal f/ ;
: flog10
flog [ 10 i->f flog ] literal f/ ;
+: truncate
+ dup 1.0 fmod f- ;
+
: floor
dup 0.0 f>= if
: floor
dup 0.0 f>= if
- dup 1.0 fmod f-
+ truncate
else
dup 1.0 fmod dup 0.0 <> if
f- 1.0 f-
else
dup 1.0 fmod dup 0.0 <> if
f- 1.0 f-
@@
-175,6
+183,18
@@
END-CODE
then
;
then
;
+: ceiling
+ dup 0.0 f>= if
+ dup 1.0 fmod dup 0.0 <> if
+ f- 1.0 f+
+ else
+ drop
+ then
+ else
+ truncate
+ then
+;
+
: fasin ( float -- res )
dup
dup f* 1.0 swap f- fsqrt
: fasin ( float -- res )
dup
dup f* 1.0 swap f- fsqrt