/all-integers-are-bignums: broken, but I don't know why.
This commit is contained in:
parent
489f008044
commit
61573d85d9
|
@ -125,6 +125,12 @@ struct cons_pointer multiply_integers( struct cons_pointer a,
|
||||||
int64_t carry = 0;
|
int64_t carry = 0;
|
||||||
|
|
||||||
if ( integerp( a ) && integerp( b ) ) {
|
if ( integerp( a ) && integerp( b ) ) {
|
||||||
|
debug_print(L"multiply_integers: ", DEBUG_ARITH);
|
||||||
|
debug_print_object(a, DEBUG_ARITH);
|
||||||
|
debug_print(L" x ", DEBUG_ARITH);
|
||||||
|
debug_print_object(b, DEBUG_ARITH);
|
||||||
|
debug_println(DEBUG_ARITH);
|
||||||
|
|
||||||
while ( !nilp( a ) || !nilp( b ) || carry != 0 ) {
|
while ( !nilp( a ) || !nilp( b ) || carry != 0 ) {
|
||||||
int64_t av =
|
int64_t av =
|
||||||
integerp( a ) ? pointer2cell( a ).payload.integer.value : 1;
|
integerp( a ) ? pointer2cell( a ).payload.integer.value : 1;
|
||||||
|
@ -134,6 +140,7 @@ struct cons_pointer multiply_integers( struct cons_pointer a,
|
||||||
__int128_t rv = ( av * bv ) + carry;
|
__int128_t rv = ( av * bv ) + carry;
|
||||||
|
|
||||||
if ( rv > LONG_MAX || rv < LONG_MIN ) {
|
if ( rv > LONG_MAX || rv < LONG_MIN ) {
|
||||||
|
debug_printf( DEBUG_ARITH, L"multiply_integers: 64 bit overflow; setting carry to %ld\n", carry);
|
||||||
carry = llabs( rv / LONG_MAX );
|
carry = llabs( rv / LONG_MAX );
|
||||||
rv = rv % LONG_MAX;
|
rv = rv % LONG_MAX;
|
||||||
} else {
|
} else {
|
||||||
|
@ -145,6 +152,9 @@ struct cons_pointer multiply_integers( struct cons_pointer a,
|
||||||
b = pointer2cell( b ).payload.integer.more;
|
b = pointer2cell( b ).payload.integer.more;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
debug_print(L"multiply_integers returning: ", DEBUG_ARITH);
|
||||||
|
debug_print_object(result, DEBUG_ARITH);
|
||||||
|
debug_println(DEBUG_ARITH);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -284,7 +284,8 @@ struct cons_pointer multiply_2( struct stack_frame *frame,
|
||||||
result = arg2;
|
result = arg2;
|
||||||
break;
|
break;
|
||||||
case INTEGERTV:
|
case INTEGERTV:
|
||||||
result = multiply_integers( arg1, arg2 );
|
result = make_integer(cell1.payload.integer.value * cell2.payload.integer.value, NIL);
|
||||||
|
//result = multiply_integers( arg1, arg2 );
|
||||||
break;
|
break;
|
||||||
case RATIOTV:
|
case RATIOTV:
|
||||||
result =
|
result =
|
||||||
|
@ -411,9 +412,8 @@ struct cons_pointer inverse( struct cons_pointer frame,
|
||||||
case RATIOTV:
|
case RATIOTV:
|
||||||
result = make_ratio( frame,
|
result = make_ratio( frame,
|
||||||
make_integer( 0 -
|
make_integer( 0 -
|
||||||
to_long_int( cell.payload.
|
to_long_int( cell.payload.ratio.
|
||||||
ratio.dividend ),
|
dividend ), NIL ),
|
||||||
NIL ),
|
|
||||||
cell.payload.ratio.divisor );
|
cell.payload.ratio.divisor );
|
||||||
break;
|
break;
|
||||||
case REALTV:
|
case REALTV:
|
||||||
|
@ -453,8 +453,7 @@ struct cons_pointer lisp_subtract( struct
|
||||||
break;
|
break;
|
||||||
case INTEGERTV:
|
case INTEGERTV:
|
||||||
result = make_integer( cell0.payload.integer.value
|
result = make_integer( cell0.payload.integer.value
|
||||||
- cell1.payload.integer.value,
|
- cell1.payload.integer.value, NIL );
|
||||||
NIL );
|
|
||||||
break;
|
break;
|
||||||
case RATIOTV:{
|
case RATIOTV:{
|
||||||
struct cons_pointer tmp =
|
struct cons_pointer tmp =
|
||||||
|
|
|
@ -83,6 +83,10 @@ void dump_object( FILE * output, struct cons_pointer pointer ) {
|
||||||
fwprintf( output,
|
fwprintf( output,
|
||||||
L"\t\tInteger cell: value %ld, count %u\n",
|
L"\t\tInteger cell: value %ld, count %u\n",
|
||||||
cell.payload.integer.value, cell.count );
|
cell.payload.integer.value, cell.count );
|
||||||
|
if (!nilp(cell.payload.integer.more)) {
|
||||||
|
fputws( L"\t\tBIGNUM! More at\n:", output);
|
||||||
|
dump_object(output, cell.payload.integer.more);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case LAMBDATV:
|
case LAMBDATV:
|
||||||
fwprintf( output, L"\t\tLambda cell;\n\t\t args: " );
|
fwprintf( output, L"\t\tLambda cell;\n\t\t args: " );
|
||||||
|
|
Loading…
Reference in a new issue