comparison src/data.c @ 2010:a9cdbfb4716e

[xemacs-hg @ 2004-04-13 15:38:30 by james] Handle leading + signs on numbers correctly.
author james
date Tue, 13 Apr 2004 15:38:42 +0000
parents cc5b615380f8
children f2fdfc131770
comparison
equal deleted inserted replaced
2009:1388c8b3e663 2010:a9cdbfb4716e
1269 #endif 1269 #endif
1270 return make_float (atof ((const char *) p)); 1270 return make_float (atof ((const char *) p));
1271 #ifdef HAVE_BIGFLOAT 1271 #ifdef HAVE_BIGFLOAT
1272 else 1272 else
1273 { 1273 {
1274 /* GMP bigfloat_set_string returns random values with initial + */
1275 if (*p == '+')
1276 p++;
1274 bigfloat_set_prec (scratch_bigfloat, bigfloat_get_default_prec ()); 1277 bigfloat_set_prec (scratch_bigfloat, bigfloat_get_default_prec ());
1275 bigfloat_set_string (scratch_bigfloat, (const char *) p, b); 1278 bigfloat_set_string (scratch_bigfloat, (const char *) p, b);
1276 return make_bigfloat_bf (scratch_bigfloat); 1279 return make_bigfloat_bf (scratch_bigfloat);
1277 } 1280 }
1278 #endif 1281 #endif
1279 } 1282 }
1280 1283
1281 #ifdef HAVE_RATIO 1284 #ifdef HAVE_RATIO
1282 if (qxestrchr (p, '/') != NULL) 1285 if (qxestrchr (p, '/') != NULL)
1283 { 1286 {
1287 /* GMP ratio_set_string returns random values with initial + sign */
1288 if (*p == '+')
1289 p++;
1284 ratio_set_string (scratch_ratio, (const char *) p, b); 1290 ratio_set_string (scratch_ratio, (const char *) p, b);
1285 return make_ratio_rt (scratch_ratio); 1291 return make_ratio_rt (scratch_ratio);
1286 } 1292 }
1287 #endif /* HAVE_RATIO */ 1293 #endif /* HAVE_RATIO */
1288 1294
1289 #ifdef HAVE_BIGNUM 1295 #ifdef HAVE_BIGNUM
1296 /* GMP bignum_set_string returns random values when the string starts with a
1297 plus sign */
1298 if (*p == '+')
1299 p++;
1290 /* GMP bignum_set_string returns random values when fed an empty string */ 1300 /* GMP bignum_set_string returns random values when fed an empty string */
1291 if (*p == '\0') 1301 if (*p == '\0')
1292 return make_int (0); 1302 return make_int (0);
1293 bignum_set_string (scratch_bignum, (const char *) p, b); 1303 bignum_set_string (scratch_bignum, (const char *) p, b);
1294 return Fcanonicalize_number (make_bignum_bg (scratch_bignum)); 1304 return Fcanonicalize_number (make_bignum_bg (scratch_bignum));