comparison src/number.c @ 4888:c27efc9acb5a

merge
author Ben Wing <ben@xemacs.org>
date Wed, 27 Jan 2010 00:37:59 -0600
parents 1e9078742fa7
children d1d4ce10c7b4 db2db229ee82
comparison
equal deleted inserted replaced
4887:a47abe9c47f2 4888:c27efc9acb5a
30 #define USED_IF_BIGFLOAT(decl) UNUSED (decl) 30 #define USED_IF_BIGFLOAT(decl) UNUSED (decl)
31 #endif 31 #endif
32 32
33 Lisp_Object Qrationalp, Qfloatingp, Qrealp; 33 Lisp_Object Qrationalp, Qfloatingp, Qrealp;
34 Lisp_Object Vdefault_float_precision; 34 Lisp_Object Vdefault_float_precision;
35 Fixnum Vmost_negative_fixnum, Vmost_positive_fixnum; 35
36 static Lisp_Object Qunsupported_type; 36 static Lisp_Object Qunsupported_type;
37 static Lisp_Object Vbigfloat_max_prec; 37 static Lisp_Object Vbigfloat_max_prec;
38 static int number_initialized; 38 static int number_initialized;
39 39
40 #ifdef HAVE_BIGNUM 40 #ifdef HAVE_BIGNUM
137 { 137 {
138 return BIGNUMP (object) ? Qt : Qnil; 138 return BIGNUMP (object) ? Qt : Qnil;
139 } 139 }
140 140
141 141
142 /********************************* Integers *********************************/
143 DEFUN ("integerp", Fintegerp, 1, 1, 0, /*
144 Return t if OBJECT is an integer, nil otherwise.
145 */
146 (object))
147 {
148 return INTEGERP (object) ? Qt : Qnil;
149 }
150
151 DEFUN ("evenp", Fevenp, 1, 1, 0, /*
152 Return t if INTEGER is even, nil otherwise.
153 */
154 (integer))
155 {
156 CONCHECK_INTEGER (integer);
157 return (BIGNUMP (integer)
158 ? bignum_evenp (XBIGNUM_DATA (integer))
159 : XTYPE (integer) == Lisp_Type_Int_Even) ? Qt : Qnil;
160 }
161
162 DEFUN ("oddp", Foddp, 1, 1, 0, /*
163 Return t if INTEGER is odd, nil otherwise.
164 */
165 (integer))
166 {
167 CONCHECK_INTEGER (integer);
168 return (BIGNUMP (integer)
169 ? bignum_oddp (XBIGNUM_DATA (integer))
170 : XTYPE (integer) == Lisp_Type_Int_Odd) ? Qt : Qnil;
171 }
172
173
174 /********************************** Ratios **********************************/ 142 /********************************** Ratios **********************************/
175 #ifdef HAVE_RATIO 143 #ifdef HAVE_RATIO
176 static void 144 static void
177 ratio_print (Lisp_Object obj, Lisp_Object printcharfun, 145 ratio_print (Lisp_Object obj, Lisp_Object printcharfun,
178 int UNUSED (escapeflag)) 146 int UNUSED (escapeflag))
268 if (RATIOP (rational)) 236 if (RATIOP (rational))
269 { 237 {
270 return Fcanonicalize_number (make_bignum_bg 238 return Fcanonicalize_number (make_bignum_bg
271 (XRATIO_DENOMINATOR (rational))); 239 (XRATIO_DENOMINATOR (rational)));
272 } 240 }
273 #endif 241 #else
274 return make_int (1); 242 return make_int (1);
275 } 243 }
276 244
277 245
278 /******************************** Bigfloats *********************************/ 246 /******************************** Bigfloats *********************************/
808 DEFSYMBOL (Qratiop); 776 DEFSYMBOL (Qratiop);
809 DEFSYMBOL (Qbigfloatp); 777 DEFSYMBOL (Qbigfloatp);
810 778
811 /* Functions */ 779 /* Functions */
812 DEFSUBR (Fbignump); 780 DEFSUBR (Fbignump);
813 DEFSUBR (Fintegerp);
814 DEFSUBR (Fevenp);
815 DEFSUBR (Foddp);
816 DEFSUBR (Fratiop); 781 DEFSUBR (Fratiop);
817 DEFSUBR (Frationalp); 782 DEFSUBR (Frationalp);
818 DEFSUBR (Fnumerator); 783 DEFSUBR (Fnumerator);
819 DEFSUBR (Fdenominator); 784 DEFSUBR (Fdenominator);
820 DEFSUBR (Fbigfloatp); 785 DEFSUBR (Fbigfloatp);
853 Vbigfloat_max_prec = make_int (EMACS_INT_MAX); 818 Vbigfloat_max_prec = make_int (EMACS_INT_MAX);
854 #else 819 #else
855 Vbigfloat_max_prec = make_int (0); 820 Vbigfloat_max_prec = make_int (0);
856 #endif /* HAVE_BIGFLOAT */ 821 #endif /* HAVE_BIGFLOAT */
857 822
858 DEFVAR_CONST_INT ("most-negative-fixnum", &Vmost_negative_fixnum /*
859 The fixnum closest in value to negative infinity.
860 */);
861 Vmost_negative_fixnum = EMACS_INT_MIN;
862
863 DEFVAR_CONST_INT ("most-positive-fixnum", &Vmost_positive_fixnum /*
864 The fixnum closest in value to positive infinity.
865 */);
866 Vmost_positive_fixnum = EMACS_INT_MAX;
867
868 Fprovide (intern ("number-types")); 823 Fprovide (intern ("number-types"));
869 #ifdef HAVE_BIGNUM 824 #ifdef HAVE_BIGNUM
870 Fprovide (intern ("bignum")); 825 Fprovide (intern ("bignum"));
871 #endif 826 #endif
872 #ifdef HAVE_RATIO 827 #ifdef HAVE_RATIO