Skip to content

Commit bd9a7f6

Browse files
authored
Merge pull request #326 from Affonso-Gui/arith-fix
Arith.c fix
2 parents a19fc42 + 5343112 commit bd9a7f6

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

lisp/c/arith.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -702,6 +702,8 @@ register pointer argv[];
702702
for (i=0; i<n; i++) fprintf(stderr, "%x ", argv[i]);
703703
fprintf(stderr, "\n"); */
704704

705+
if (n==0) return(makeint(1));
706+
705707
i=1;
706708
a=argv[0];
707709
if (isint(a)) { is=intval(a); goto ITIMES;}
@@ -815,9 +817,7 @@ pointer argv[];
815817
else if (pisbignum(a)) { rs=copy_big(a); goto bquo;}
816818
else error(E_NONUMBER);
817819

818-
if (n==1) {
819-
fs=fltval(a);
820-
return(makeflt(1.0/fs));}
820+
if (n==1) return(makeflt(1.0/is));
821821

822822
while (i<n) {
823823
a=argv[i];
@@ -1159,6 +1159,8 @@ pointer LOGAND(context *ctx, int n, pointer argv[])
11591159
eusinteger_t *rbv, *bbv, *pbv;
11601160
pointer b,p,r=argv[0];
11611161

1162+
if (n==0) return(makeint(~0));
1163+
11621164
if (isbignum(r)) {
11631165
r=copy_big(r); rsize=bigsize(r); rbv=bigvec(r);
11641166
p=argv[i++];
@@ -1373,11 +1375,11 @@ pointer argv[];
13731375
#else
13741376
register unsigned int val,target,mask=~0;
13751377
#endif
1376-
ckarg(4);
1378+
ckarg2(3,4);
13771379
val=ckintval(argv[0]);
13781380
target=ckintval(argv[1]);
13791381
pos=ckintval(argv[2]);
1380-
width=ckintval(argv[3]);
1382+
if (n==4) width=ckintval(argv[3]);
13811383
mask=mask<<(WORD_SIZE-(pos+width));
13821384
mask=mask>>(WORD_SIZE-width);
13831385
val &= mask;

0 commit comments

Comments
 (0)