Mercurial > hg > xemacs-beta
comparison src/number.c @ 5118:e0db3c197671 ben-lisp-object
merge up to latest default branch, doesn't compile yet
author | Ben Wing <ben@xemacs.org> |
---|---|
date | Sat, 26 Dec 2009 21:18:49 -0600 |
parents | 3742ea8250b5 b5e1d4f6b66f |
children | 623d57b7fbe8 |
comparison
equal
deleted
inserted
replaced
5117:3742ea8250b5 | 5118:e0db3c197671 |
---|---|
39 | 39 |
40 #ifdef HAVE_BIGNUM | 40 #ifdef HAVE_BIGNUM |
41 bignum scratch_bignum, scratch_bignum2; | 41 bignum scratch_bignum, scratch_bignum2; |
42 #endif | 42 #endif |
43 #ifdef HAVE_RATIO | 43 #ifdef HAVE_RATIO |
44 ratio scratch_ratio; | 44 ratio scratch_ratio, scratch_ratio2; |
45 #endif | 45 #endif |
46 #ifdef HAVE_BIGFLOAT | 46 #ifdef HAVE_BIGFLOAT |
47 bigfloat scratch_bigfloat, scratch_bigfloat2; | 47 bigfloat scratch_bigfloat, scratch_bigfloat2; |
48 #endif | 48 #endif |
49 | 49 |
104 { XD_OPAQUE_DATA_CONVERTIBLE, offsetof (Lisp_Bignum, data), | 104 { XD_OPAQUE_DATA_CONVERTIBLE, offsetof (Lisp_Bignum, data), |
105 0, { &bignum_opc }, XD_FLAG_NO_KKCC }, | 105 0, { &bignum_opc }, XD_FLAG_NO_KKCC }, |
106 { XD_END } | 106 { XD_END } |
107 }; | 107 }; |
108 | 108 |
109 DEFINE_BASIC_LISP_OBJECT ("bignum", bignum, 0, bignum_print, | 109 DEFINE_DUMPABLE_FROB_BLOCK_LISP_OBJECT ("bignum", bignum, 0, bignum_print, |
110 0, bignum_equal, bignum_hash, | 110 0, bignum_equal, bignum_hash, |
111 bignum_description, Lisp_Bignum); | 111 bignum_description, Lisp_Bignum); |
112 | 112 |
113 #endif /* HAVE_BIGNUM */ | 113 #endif /* HAVE_BIGNUM */ |
114 | 114 |
181 static const struct memory_description ratio_description[] = { | 181 static const struct memory_description ratio_description[] = { |
182 { XD_OPAQUE_PTR, offsetof (Lisp_Ratio, data) }, | 182 { XD_OPAQUE_PTR, offsetof (Lisp_Ratio, data) }, |
183 { XD_END } | 183 { XD_END } |
184 }; | 184 }; |
185 | 185 |
186 DEFINE_NONDUMPABLE_BASIC_LISP_OBJECT ("ratio", ratio, 0, ratio_print, | 186 DEFINE_NODUMP_FROB_BLOCK_LISP_OBJECT ("ratio", ratio, 0, ratio_print, |
187 0, ratio_equal, ratio_hash, | 187 0, ratio_equal, ratio_hash, |
188 ratio_description, Lisp_Ratio); | 188 ratio_description, Lisp_Ratio); |
189 | 189 |
190 #endif /* HAVE_RATIO */ | 190 #endif /* HAVE_RATIO */ |
191 | 191 |
192 Lisp_Object Qratiop; | 192 Lisp_Object Qratiop; |
193 | 193 |
268 static const struct memory_description bigfloat_description[] = { | 268 static const struct memory_description bigfloat_description[] = { |
269 { XD_OPAQUE_PTR, offsetof (Lisp_Bigfloat, bf) }, | 269 { XD_OPAQUE_PTR, offsetof (Lisp_Bigfloat, bf) }, |
270 { XD_END } | 270 { XD_END } |
271 }; | 271 }; |
272 | 272 |
273 DEFINE_BASIC_LISP_OBJECT ("bigfloat", bigfloat, 0, | 273 DEFINE_DUMPABLE_FROB_BLOCK_LISP_OBJECT ("bigfloat", bigfloat, 0, |
274 bigfloat_print, 0, | 274 bigfloat_print, 0, |
275 bigfloat_equal, bigfloat_hash, | 275 bigfloat_equal, bigfloat_hash, |
276 bigfloat_description, Lisp_Bigfloat); | 276 bigfloat_description, Lisp_Bigfloat); |
277 | 277 |
278 #endif /* HAVE_BIGFLOAT */ | 278 #endif /* HAVE_BIGFLOAT */ |
406 bignum_fits_long_p (XRATIO_DENOMINATOR (number)) && | 406 bignum_fits_long_p (XRATIO_DENOMINATOR (number)) && |
407 bignum_to_long (XRATIO_DENOMINATOR (number)) == 1L) | 407 bignum_to_long (XRATIO_DENOMINATOR (number)) == 1L) |
408 number = make_bignum_bg (XRATIO_NUMERATOR (number)); | 408 number = make_bignum_bg (XRATIO_NUMERATOR (number)); |
409 #endif | 409 #endif |
410 #ifdef HAVE_BIGNUM | 410 #ifdef HAVE_BIGNUM |
411 if (BIGNUMP (number) && bignum_fits_int_p (XBIGNUM_DATA (number))) | 411 if (BIGNUMP (number) && bignum_fits_emacs_int_p (XBIGNUM_DATA (number))) |
412 { | 412 { |
413 int n = bignum_to_int (XBIGNUM_DATA (number)); | 413 EMACS_INT n = bignum_to_emacs_int (XBIGNUM_DATA (number)); |
414 if (NUMBER_FITS_IN_AN_EMACS_INT (n)) | 414 if (NUMBER_FITS_IN_AN_EMACS_INT (n)) |
415 number = make_int (n); | 415 number = make_int (n); |
416 } | 416 } |
417 #endif | 417 #endif |
418 return number; | 418 return number; |
559 #endif /* HAVE_RATIO */ | 559 #endif /* HAVE_RATIO */ |
560 case FLOAT_T: | 560 case FLOAT_T: |
561 switch (type) | 561 switch (type) |
562 { | 562 { |
563 case FIXNUM_T: | 563 case FIXNUM_T: |
564 return Ftruncate (number); | 564 return Ftruncate (number, Qnil); |
565 case BIGNUM_T: | 565 case BIGNUM_T: |
566 #ifdef HAVE_BIGNUM | 566 #ifdef HAVE_BIGNUM |
567 bignum_set_double (scratch_bignum, XFLOAT_DATA (number)); | 567 bignum_set_double (scratch_bignum, XFLOAT_DATA (number)); |
568 return make_bignum_bg (scratch_bignum); | 568 return make_bignum_bg (scratch_bignum); |
569 #else | 569 #else |
851 bignum_init (scratch_bignum2); | 851 bignum_init (scratch_bignum2); |
852 #endif | 852 #endif |
853 | 853 |
854 #ifdef HAVE_RATIO | 854 #ifdef HAVE_RATIO |
855 ratio_init (scratch_ratio); | 855 ratio_init (scratch_ratio); |
856 ratio_init (scratch_ratio2); | |
856 #endif | 857 #endif |
857 | 858 |
858 #ifdef HAVE_BIGFLOAT | 859 #ifdef HAVE_BIGFLOAT |
859 bigfloat_init (scratch_bigfloat); | 860 bigfloat_init (scratch_bigfloat); |
860 bigfloat_init (scratch_bigfloat2); | 861 bigfloat_init (scratch_bigfloat2); |