Add ash.
* math.c (ash): New function. * tests/scm.test (ash, ash -1): New tests.
This commit is contained in:
parent
7d5c3a0201
commit
e97d99c03a
10
math.c
10
math.c
|
@ -143,3 +143,13 @@ logior (SCM x) ///((arity . n))
|
|||
}
|
||||
return make_number (n);
|
||||
}
|
||||
|
||||
SCM
|
||||
ash (SCM n, SCM count)
|
||||
{
|
||||
assert (TYPE (n) == NUMBER);
|
||||
assert (TYPE (count) == NUMBER);
|
||||
int cn = VALUE (n);
|
||||
int ccount = VALUE (count);
|
||||
return make_number ((ccount < 0) ? cn >> -ccount : cn << ccount);
|
||||
}
|
||||
|
|
|
@ -60,6 +60,10 @@ exit $?
|
|||
(pass-if "modulo" (seq? (modulo 11 3) 2))
|
||||
(pass-if "expt" (seq? (expt 2 3) 8))
|
||||
(pass-if "logior" (seq? (logior 0 1 2 4) 7))
|
||||
(pass-if-equal "ash"
|
||||
8 (ash 1 3))
|
||||
(pass-if-equal "ash -1"
|
||||
5 (ash 10 -1))
|
||||
|
||||
(pass-if "=" (seq? 3 '3))
|
||||
(pass-if "= 2" (not (= 3 '4)))
|
||||
|
|
Loading…
Reference in a new issue