add f:sin, f:tan, f:cos
FossilOrigin-Name: 613582429fb75cee604f8a4e8402286a3cf76b561782a3dbb2156e0a19a3d0ff
This commit is contained in:
parent
b8f7dd4d62
commit
53dc840260
5 changed files with 65 additions and 2 deletions
|
@ -1730,6 +1730,18 @@ Class Handler: class:word | Namespace: f | Interface Layer: rre
|
|||
|
||||
----------------------------------------------------------------
|
||||
|
||||
f:cos
|
||||
|
||||
Data: -
|
||||
Addr: -
|
||||
Float: f-f
|
||||
|
||||
Return the cosine of a floating point number.
|
||||
|
||||
Class Handler: class:word | Namespace: f | Interface Layer: rre
|
||||
|
||||
----------------------------------------------------------------
|
||||
|
||||
f:depth
|
||||
|
||||
Data: -n
|
||||
|
@ -1886,6 +1898,18 @@ Class Handler: class:word | Namespace: f | Interface Layer: rre
|
|||
|
||||
----------------------------------------------------------------
|
||||
|
||||
f:sin
|
||||
|
||||
Data: -
|
||||
Addr: -
|
||||
Float: f-f
|
||||
|
||||
Return the sine of a floating point number.
|
||||
|
||||
Class Handler: class:word | Namespace: f | Interface Layer: rre
|
||||
|
||||
----------------------------------------------------------------
|
||||
|
||||
f:swap
|
||||
|
||||
Data: -
|
||||
|
@ -1898,6 +1922,18 @@ Class Handler: class:word | Namespace: f | Interface Layer: rre
|
|||
|
||||
----------------------------------------------------------------
|
||||
|
||||
f:tan
|
||||
|
||||
Data: -
|
||||
Addr: -
|
||||
Float: f-f
|
||||
|
||||
Return the tangent of a floating point number.
|
||||
|
||||
Class Handler: class:word | Namespace: f | Interface Layer: rre
|
||||
|
||||
----------------------------------------------------------------
|
||||
|
||||
f:to-number
|
||||
|
||||
Data: -n
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -653,6 +653,21 @@ void float_to_number() {
|
|||
stack_push((CELL)a);
|
||||
}
|
||||
|
||||
void float_sin() {
|
||||
double a = float_pop();
|
||||
float_push(sin(a));
|
||||
}
|
||||
|
||||
void float_cos() {
|
||||
double a = float_pop();
|
||||
float_push(cos(a));
|
||||
}
|
||||
|
||||
void float_tan() {
|
||||
double a = float_pop();
|
||||
float_push(tan(a));
|
||||
}
|
||||
|
||||
void ngaFloatingPointUnit() {
|
||||
switch (stack_pop()) {
|
||||
case 0: float_from_number();
|
||||
|
@ -693,6 +708,12 @@ void ngaFloatingPointUnit() {
|
|||
break;
|
||||
case 18: float_to_number();
|
||||
break;
|
||||
case 19: float_sin();
|
||||
break;
|
||||
case 20: float_cos();
|
||||
break;
|
||||
case 21: float_tan();
|
||||
break;
|
||||
default: ;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,6 +41,9 @@ This is a set of extensions for RRE.
|
|||
:prefix:. (s-__f:-f)
|
||||
compiling? [ s:keep ] [ s:temp ] choose &s:to-float class:word ; immediate
|
||||
:putf (f:-) f:to-string puts ;
|
||||
:f:sin (f:f-f) #19 `-6000 ;
|
||||
:f:cos (f:f-f) #20 `-6000 ;
|
||||
:f:tan (f:f-f) #21 `-6000 ;
|
||||
~~~
|
||||
|
||||
---------------------------------------------------------------
|
||||
|
|
|
@ -140,6 +140,7 @@ f:- - - FF-F Subtract F2 from F1 returing the result. class:word {n/a} {n/a} f
|
|||
f:-eq? -f - FF- Compare two floating point values for inequality. Returns `TRUE` if they are not equal or `FALSE` otherwise. class:word {n/a} {n/a} f rre
|
||||
f:/ - - FF-F Divide floating point value F1 by F2. class:word {n/a} {n/a} f rre
|
||||
f:abs - - F-F Return the absolute value for a floating point value. class:word {n/a} {n/a} f rre
|
||||
f:cos - - f-f Return the cosine of a floating point number. class:word {n/a} {n/a} f rre
|
||||
f:depth -n - - Return the number of items on the floating point stack. class:word {n/a} {n/a} f rre
|
||||
f:drop - - F- Discard the top item on the floating point stack. class:word {n/a} {n/a} f rre
|
||||
f:dup - - F-FF Duplicate the top item on the floating point stack. class:word {n/a} {n/a} f rre
|
||||
|
@ -153,7 +154,9 @@ f:negative? -f - F- Return `TRUE` if floating point value is negative or `FALSE`
|
|||
f:over - - FG-FGF Put a copy of the second floating point value over the top one. class:word {n/a} {n/a} f rre
|
||||
f:positive? -f - F- Return `TRUE` if floating point value is positive or `FALSE` otherwise. class:word {n/a} {n/a} f rre
|
||||
f:power - - FF-F Return F1^F2 for floating point values. class:word {n/a} {n/a} f rre
|
||||
f:sin - - f-f Return the sine of a floating point number. class:word {n/a} {n/a} f rre
|
||||
f:swap - - FG-GF Exchange the top and second items on the floating point stack. class:word {n/a} {n/a} f rre
|
||||
f:tan - - f-f Return the tangent of a floating point number. class:word {n/a} {n/a} f rre
|
||||
f:to-number -n - F- Convert a floating point value into a number. class:word {n/a} {n/a} f rre
|
||||
f:to-string -s - F- Convert a floating point value into a string. class:word {n/a} {n/a} f rre
|
||||
f:tuck - - FG-GFG Tuck a copy of the top floating point value under the second one. class:word {n/a} {n/a} f rre
|
||||
|
|
|
Loading…
Reference in a new issue