comparison src/number.c @ 5602:c9e5612f5424

Support the MP library on recent FreeBSD, have it pass relevant tests. src/ChangeLog addition: 2011-11-26 Aidan Kehoe <kehoea@parhasard.net> * number-mp.c (bignum_to_string): Don't overwrite the accumulator we've just set up for this function. * number-mp.c (BIGNUM_TO_TYPE): mp_itom() doesn't necessarily do what this code used to think with negative numbers, it can treat them as unsigned ints. Subtract numbers from bignum_zero instead of multiplying them by -1 to convert them to their negative equivalents. * number-mp.c (bignum_to_int): * number-mp.c (bignum_to_uint): * number-mp.c (bignum_to_long): * number-mp.c (bignum_to_ulong): * number-mp.c (bignum_to_double): Use the changed BIGNUM_TO_TYPE() in these functions. * number-mp.c (bignum_ceil): * number-mp.c (bignum_floor): In these functions, be more careful about rounding to positive and negative infinity, respectively. Don't use the sign of QUOTIENT when working out out whether to add or subtract one, rather use the sign QUOTIENT would have if arbitrary-precision division were done. * number-mp.h: * number-mp.h (MP_GCD): Wrap #include <mp.h> in BEGIN_C_DECLS/END_C_DECLS. * number.c (Fbigfloat_get_precision): * number.c (Fbigfloat_set_precision): Don't attempt to call XBIGFLOAT_GET_PREC if this build doesn't support big floats.
author Aidan Kehoe <kehoea@parhasard.net>
date Sat, 26 Nov 2011 17:59:14 +0000
parents 56144c8593a8
children a2912073be85
comparison
equal deleted inserted replaced
5601:3e5d5e8e4bb7 5602:c9e5612f5424
326 Return the precision of bigfloat F as an integer. 326 Return the precision of bigfloat F as an integer.
327 */ 327 */
328 (f)) 328 (f))
329 { 329 {
330 CHECK_BIGFLOAT (f); 330 CHECK_BIGFLOAT (f);
331 #ifdef HAVE_BIGFLOAT
331 #ifdef HAVE_BIGNUM 332 #ifdef HAVE_BIGNUM
332 bignum_set_ulong (scratch_bignum, XBIGFLOAT_GET_PREC (f)); 333 bignum_set_ulong (scratch_bignum, XBIGFLOAT_GET_PREC (f));
333 return Fcanonicalize_number (make_bignum_bg (scratch_bignum)); 334 return Fcanonicalize_number (make_bignum_bg (scratch_bignum));
334 #else 335 #else
335 return make_fixnum ((int) XBIGFLOAT_GET_PREC (f)); 336 return make_fixnum ((int) XBIGFLOAT_GET_PREC (f));
337 #endif
336 #endif 338 #endif
337 } 339 }
338 340
339 DEFUN ("bigfloat-set-precision", Fbigfloat_set_precision, 2, 2, 0, /* 341 DEFUN ("bigfloat-set-precision", Fbigfloat_set_precision, 2, 2, 0, /*
340 Set the precision of F, a bigfloat, to PRECISION, a nonnegative integer. 342 Set the precision of F, a bigfloat, to PRECISION, a nonnegative integer.
362 else 364 else
363 { 365 {
364 dead_wrong_type_argument (Qintegerp, f); 366 dead_wrong_type_argument (Qintegerp, f);
365 return Qnil; 367 return Qnil;
366 } 368 }
367 369 #ifdef HAVE_BIGFLOAT
368 XBIGFLOAT_SET_PREC (f, prec); 370 XBIGFLOAT_SET_PREC (f, prec);
371 #endif
369 return Fbigfloat_get_precision (f); 372 return Fbigfloat_get_precision (f);
370 } 373 }
371 374
372 static int 375 static int
373 default_float_precision_changed (Lisp_Object UNUSED (sym), Lisp_Object *val, 376 default_float_precision_changed (Lisp_Object UNUSED (sym), Lisp_Object *val,