From: Terrance S. <ts...@us...> - 2007-04-28 13:29:51
|
Update of /cvsroot/xsb/XSB/emu In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv3451 Modified Files: builtin.c Log Message: Changes to XSB_POW, which supports exp/2, so that it handles floats properly. This is useful, for instance, to find geometric means. Index: builtin.c =================================================================== RCS file: /cvsroot/xsb/XSB/emu/builtin.c,v retrieving revision 1.280 retrieving revision 1.281 diff -u -r1.280 -r1.281 --- builtin.c 20 Apr 2007 14:40:52 -0000 1.280 +++ builtin.c 28 Apr 2007 13:29:49 -0000 1.281 @@ -2504,10 +2504,22 @@ break; /* TLS: useful for power function -- see eval.P */ - case XSB_POW: - ctop_float(CTXTc 3,pow(ptoc_int(CTXTc 1),ptoc_int(CTXTc 2))); - return TRUE ; - + case XSB_POW: { + Cell val = ptoc_tag(CTXTc 1); + if (isofloat(ptoc_tag(CTXTc 1))) { + if (isofloat(ptoc_tag(CTXTc 2))) + ctop_float(CTXTc 3,powf(ptoc_float(CTXTc 1),ptoc_float(CTXTc 2))); + else + ctop_float(CTXTc 3,powl(ptoc_float(CTXTc 1),ptoc_int(CTXTc 2))); + } + else { + if (isofloat(ptoc_tag(CTXTc 2))) + ctop_float(CTXTc 3,powl(ptoc_int(CTXTc 1),ptoc_float(CTXTc 2))); + else + ctop_int(CTXTc 3,pow(ptoc_int(CTXTc 1),ptoc_int(CTXTc 2))); + } + return TRUE ; + } case PRINT_LS: print_ls(CTXTc 1) ; return TRUE ; case PRINT_TR: print_tr(CTXTc 1) ; return TRUE ; case PRINT_HEAP: print_heap(CTXTc 0,2000,1) ; return TRUE ; |