55 switch(num1+num2*2+num3*4) {
73 else if (val1!=1.0 && arg2==arg3)
83 else if (val2!=1.0 && arg1==arg3)
118 success=(val3==val1*val2);
153 if (success && arg2) {
165 switch(num1+num2*2+num3*4) {
196 Errorline(
"division by zero in %P.\n",t);
204 Errorline(
"division by zero in %P.\n",t);
209 if (val3==1.0 && arg1!=arg2) {
212 else if (val3!=1.0 && arg1==arg2)
232 Errorline(
"division by zero in %P.\n",t);
240 success=(val3==val1/val2);
243 Errorline(
"division by zero in %P.\n",t);
279 if (success && arg2) {
291 switch(num1+num2*2+num3*4) {
324 Errorline(
"division by zero in %P.\n",t);
334 Errorline(
"division by zero in %P.\n",t);
340 if (val3!=floor(val3))
return FALSE;
341 if (val3==1.0 && arg1!=arg2) {
344 else if (val3!=1.0 && arg1==arg2)
356 if (val3!=floor(val3))
return FALSE;
365 tmp=trunc(val1/val3);
368 else if (val3==trunc(val1/tmp)) {
370 if ((tmp> 1 && val3==trunc(val1/(tmp-1))) ||
371 (tmp< -1 && val3==trunc(val1/(tmp+1))))
387 if (val3!=floor(val3))
return FALSE;
397 Errorline(
"division by zero in %P.\n",t);
408 success=(val3==trunc(val1/val2));
411 Errorline(
"division by zero in %P.\n",t);
451 switch(num1+num3*4) {
462 success=(val3==(floorflag?floor(val1):ceil(val1)));
521 switch(num1+num3*4) {
530 Errorline(
"square root of negative number in %P.\n",t);
537 success=(val3*val3==val1 || (val1>=0 && val3==sqrt(val1)));
538 if (val1<0)
Errorline(
"square root of negative number in %P.\n",t);
576 switch(num1+num3*4) {
581 ans=(trigflag==
SINFLAG?sin(val1):
583 (trigflag==
TANFLAG?tan(val1):0.0)));
587 if (trigflag==
TANFLAG || (val3>= -1 && val3<=1)) {
588 ans=(trigflag==
SINFLAG?asin(val3):
590 (trigflag==
TANFLAG?atan(val3):0.0)));
597 ans=(trigflag==
SINFLAG?asin(val1):
599 (trigflag==
TANFLAG?atan(val1):0.0)));
669 switch(num1+num3*4) {
671 if (arg1==arg3)
return FALSE;
685 success=(val3==val1);
718 if(success && arg2) {
730 switch(num1+num2*2+num3*4) {
767 success=(val3==(
REAL)(((
unsigned long)val1) & ((
unsigned long)val2)));
800 if(success && arg2) {
812 switch(num1+num2*2+num3*4) {
835 success=(val3==(
REAL)(((
unsigned long)val1) | ((
unsigned long)val2)));
881 REAL val1,val2,val3,ans;
891 if(success && arg2) {
903 switch(num1+num2*2+num3*4) {
921 ans=(
REAL)(dir?(
long)val1>>(long)val2:(
long)val1<<(long)val2);
927 ans=(
REAL)(dir?(
long)val1>>(long)val2:(
long)val1<<(long)val2);
960 if(success && arg2) {
972 switch(num1+num2*2+num3*4) {
995 success=(val3==(
REAL)((
unsigned long)val1 % (
unsigned long)val2));
1020 long num1,num2,num3;
1021 REAL val1,val2,val3;
1031 if(success && arg2) {
1043 switch(num1+num2*2+num3*4) {
1047 else if (arg2==arg3)
1088 success=(val3==val1+val2);
1136 long num1,num2,num3;
1137 REAL val1,val2,val3;
1147 if(success && arg2) {
1159 switch(num1+num2*2+num3*4) {
1163 else if (arg1==arg2)
1202 success=(val3==val1-val2);
1211 switch(num1+4*num3) {
1222 success=(val1== -val3);
1258 switch(num1+num3*4) {
1268 (val1==0)?
"zero":
"a negative number",t);
1275 success=(exp(val3)==val1 || (val1>0 && val3==log(val1)));
1278 (val1==0)?
"zero":
"a negative number",t);
1315 switch(num1+num3*4) {
1329 success=(exp(val1)==val3 || (val3>0 && val1==log(val3)));
static long c_mult()
multiplication
void new_built_in(ptr_module m, char *s, def_type t, long(*r)())
new_built_in
void insert_math_builtins()
insert math builtins into table
#define function_it
was enum (def_type) in extern.h now there is typedef ptr_definition
void get_two_args(ptr_node t, ptr_psi_term *a, ptr_psi_term *b)
get_two_args
static long c_shift_right()
void residuate(ptr_psi_term t)
residuate
void push_goal(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
push_goal
static long c_log()
natural logarithm
static long c_shift(long dir)
bitwise shift
static long c_shift_left()
bitwise shift left
static long c_sub()
subtraction
static long c_bit_not()
bitwise not
ptr_module syntax_module
Module for minimal Prolog syntax.
long get_real_value(ptr_psi_term t, REAL *v, long *n)
get_real_value
static long c_div()
division
static long c_floor()
floor
void nonnum_warning(ptr_psi_term t, ptr_psi_term arg1, ptr_psi_term arg2)
nonnum_warning
void get_one_arg(ptr_node t, ptr_psi_term *a)
get_one_arg
long bit_not_warning(ptr_psi_term arg, REAL val)
bit_not_warning
#define set_1
Set constants for deref_args in lefun.c.
static long c_intdiv()
integer division
#define REAL
Which C type to use to represent reals and integers in Wild_Life.
static long c_bit_or()
bitwise or
static long c_bit_and()
bitwise and
static long c_ceiling()
ceiling
void Errorline(char *format,...)
Errorline.
#define set_1_2
Set constants for deref_args in lefun.c.
void residuate2(ptr_psi_term u, ptr_psi_term v)
residuate2
static long c_exp()
exponential
#define TRUE
Standard boolean.
#define FALSE
Standard boolean.
#define SINFLAG
flag to c_trig to compute sin
static long c_cos()
cosine
#define COSFLAG
flag to c_trig to compute cos
long shift_warning(long dir, ptr_psi_term arg, REAL val)
shift_warning
void residuate3(ptr_psi_term u, ptr_psi_term v, ptr_psi_term w)
residuate3
static long c_floor_ceiling(long floorflag)
floor & ceiling
#define unify
was enum (goal) – but must be long for error.c - now typedef
long bit_or_warning(ptr_psi_term arg, REAL val)
bit_or_warning
ptr_module bi_module
Module for public built-ins.
static long c_sin()
sin Return the sine of the argument
static long c_add()
addition
long unify_real_result(ptr_psi_term t, REAL v)
unify_real_result
long mod_warning(ptr_psi_term arg, REAL val, int zero)
mod_warning
static long c_sqrt()
square root
static long c_trig(long trigflag)
trig functions
long int_div_warning(ptr_psi_term arg, REAL val)
int_div_warning
static long c_tan()
tangent
#define TANFLAG
flag to c_trig to compute tan
long bit_and_warning(ptr_psi_term arg, REAL val)
bit_and_warning
static long c_mod()
modulo