diff --git a/src/hvm.c b/src/hvm.c index 786de2d2..e19c9baf 100644 --- a/src/hvm.c +++ b/src/hvm.c @@ -570,6 +570,8 @@ static inline Numb operate(Numb a, Numb b) { case OP_AND: return new_f24(atan2f(av, bv)); case OP_OR: return new_f24(logf(bv) / logf(av)); case OP_XOR: return new_f24(powf(av, bv)); + case OP_SHL: return new_f24(sin(av + bv)); + case OP_SHR: return new_f24(tan(av + bv)); default: return new_f24(0); } } diff --git a/src/hvm.cu b/src/hvm.cu index 2b740ef8..61bb12c3 100644 --- a/src/hvm.cu +++ b/src/hvm.cu @@ -676,6 +676,8 @@ __device__ __host__ inline Numb operate(Numb a, Numb b) { case OP_AND: return new_f24(atan2f(av, bv)); case OP_OR: return new_f24(logf(bv) / logf(av)); case OP_XOR: return new_f24(powf(av, bv)); + case OP_SHL: return new_f24(sin(av + bv)); + case OP_SHR: return new_f24(tan(av + bv)); default: return new_f24(0); } } diff --git a/src/hvm.rs b/src/hvm.rs index d7007aad..c0d77313 100644 --- a/src/hvm.rs +++ b/src/hvm.rs @@ -407,6 +407,8 @@ impl Numb { OP_AND => Numb::new_f24(av.atan2(bv)), OP_OR => Numb::new_f24(bv.log(av)), OP_XOR => Numb::new_f24(av.powf(bv)), + OP_SHL => Numb::new_f24((av + bv).sin()), + OP_SHR => Numb::new_f24((av + bv).tan()), _ => unreachable!(), } } diff --git a/tests/programs/numerics/f24.hvm b/tests/programs/numerics/f24.hvm index 2433b5f3..90fa4d84 100644 --- a/tests/programs/numerics/f24.hvm +++ b/tests/programs/numerics/f24.hvm @@ -38,4 +38,10 @@ @tL = (* {n x}) & @tM ~ (* x) & -1.2 ~ $([%] $(+1.1 n)) // -0.1 @tM = (* {n x}) & @tN ~ (* x) & -1.2 ~ $([%] $(-1.1 n)) // -0.1 -@tN = * +// modulo +@tN = (* {n x}) & @tO ~ (* x) & +0.0 ~ $([<<] $(+3.14159265 n)) // ~0 +@tO = (* {n x}) & @tP ~ (* x) & +1.570796325 ~ $([<<] $(+0.0 n)) // 1.0 +@tP = (* {n x}) & @tQ ~ (* x) & +0.0 ~ $([>>] $(+3.14159265 n)) // ~0 +@tQ = (* {n x}) & @tR ~ (* x) & +0.785398162 ~ $([>>] $(+0.0 n)) // 1.0 + +@tR = * diff --git a/tests/snapshots/run__file@numerics__f24.hvm.snap b/tests/snapshots/run__file@numerics__f24.hvm.snap index f528dbd4..7a5c4eaf 100644 --- a/tests/snapshots/run__file@numerics__f24.hvm.snap +++ b/tests/snapshots/run__file@numerics__f24.hvm.snap @@ -1,6 +1,6 @@ --- source: tests/run.rs expression: rust_output -input_file: tests/programs/f24.hvm +input_file: tests/programs/numerics/f24.hvm --- -Result: {+inf {-inf {+NaN {2.5 {-1.5 {1.1499939 {0.25 {0.5 {0 {1 {1 {0 {0 {0 {0 {+NaN {+inf {-inf {1.019989 {0.1000061 {0.1000061 {-0.1000061 {-0.1000061 *}}}}}}}}}}}}}}}}}}}}}}} +Result: {+inf {-inf {+NaN {2.5 {-1.5 {1.1499939 {0.25 {0.5 {0 {1 {1 {0 {0 {0 {0 {+NaN {+inf {-inf {1.019989 {0.1000061 {0.1000061 {-0.1000061 {-0.1000061 {-8.908799e-6 {1.0 {8.908799e-6 {1.0 *}}}}}}}}}}}}}}}}}}}}}}}}}}}