comparison src/floatfns.c @ 5912:47ffa085a9ad

Fix a bug when passing a float to truncate and giving a bignum result. src/ChangeLog addition: 2015-05-10 Aidan Kehoe <kehoea@parhasard.net> * floatfns.c (truncate_one_float): Fix a bug here when double_to_integer() (and previously float_to_int()) returned a bignum; this was silently treated as a fixnum, giving consistently incorrect remainders and less consistently-incorrect but still buggy divisors. tests/ChangeLog addition: Check that a bug when supplying #'truncate with one float that rounds to a bignum, has been fixed.
author Aidan Kehoe <kehoea@parhasard.net>
date Sun, 10 May 2015 23:55:41 +0100
parents 48386fd60fd0
children
comparison
equal deleted inserted replaced
5911:48386fd60fd0 5912:47ffa085a9ad
2261 Lisp_Object res0 2261 Lisp_Object res0
2262 = double_to_integer (XFLOAT_DATA (number), MAYBE_EFF ("truncate"), 2262 = double_to_integer (XFLOAT_DATA (number), MAYBE_EFF ("truncate"),
2263 number, Qunbound); 2263 number, Qunbound);
2264 if (return_float) 2264 if (return_float)
2265 { 2265 {
2266 res0 = make_float ((double)XFIXNUM(res0)); 2266 res0 = make_float (extract_float (res0));
2267 return values2 (res0, make_float ((XFLOAT_DATA (number) 2267 return values2 (res0, make_float ((XFLOAT_DATA (number)
2268 - XFLOAT_DATA (res0)))); 2268 - XFLOAT_DATA (res0))));
2269 } 2269 }
2270 else 2270 else
2271 { 2271 {
2272 return values2 (res0, make_float (XFLOAT_DATA (number) 2272 return values2 (res0, make_float (XFLOAT_DATA (number)
2273 - XREALFIXNUM (res0))); 2273 - extract_float (res0)));
2274 } 2274 }
2275 } 2275 }
2276 2276
2277 EXFUN (Fftruncate, 2); 2277 EXFUN (Fftruncate, 2);
2278 2278