[gcalctool] Increase accuracy of internal calculations, don't crash printing numbers when they get too large
- From: Robert Ancell <rancell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gcalctool] Increase accuracy of internal calculations, don't crash printing numbers when they get too large
- Date: Sun, 29 Aug 2010 23:25:13 +0000 (UTC)
commit 267eef2f08067ca78ef5042600c049f808b49ad2
Author: Robert Ancell <robert ancell canonical com>
Date: Mon Aug 30 09:20:24 2010 +1000
Increase accuracy of internal calculations, don't crash printing numbers when they get too large
NEWS | 5 +++++
src/mp-convert.c | 5 +++--
src/mp-internal.h | 2 +-
3 files changed, 9 insertions(+), 3 deletions(-)
---
diff --git a/NEWS b/NEWS
index 3087d9b..09146cf 100644
--- a/NEWS
+++ b/NEWS
@@ -3,6 +3,11 @@
* Copyright (c) 1987-2009 Sun Microsystems, Inc.
* All Rights Reserved.
*/
+
+Overview of changes in gcalctool 5.31.91
+
+ * Increase accuracy of internal calculations, don't crash printing numbers
+ when they get too large.
Overview of changes in gcalctool 5.31.90
diff --git a/src/mp-convert.c b/src/mp-convert.c
index 8964a77..59d238a 100644
--- a/src/mp-convert.c
+++ b/src/mp-convert.c
@@ -534,15 +534,16 @@ mp_cast_to_string_real(const MPNumber *x, int default_base, int base, int accura
mp_set_from_mp(&integer_component, &temp);
do {
MPNumber t, t2, t3;
+ int64_t d;
mp_divide_integer(&temp, base, &t);
mp_floor(&t, &t);
mp_multiply_integer(&t, base, &t2);
mp_subtract(&temp, &t2, &t3);
- mp_floor(&t3, &t3);
- g_string_prepend_c(string, digits[mp_cast_to_int(&t3)]);
+ d = mp_cast_to_int(&t3);
+ g_string_prepend_c(string, d < 16 ? digits[d] : '?');
mp_set_from_mp(&t, &temp);
} while (!mp_is_zero(&temp));
diff --git a/src/mp-internal.h b/src/mp-internal.h
index 78d1b31..94b1530 100644
--- a/src/mp-internal.h
+++ b/src/mp-internal.h
@@ -36,7 +36,7 @@
// mperr("MP_SIZE TOO SMALL IN CALL TO MPSET, INCREASE MP_SIZE AND DIMENSIONS OF MP ARRAYS TO AT LEAST %d ***", MP.t);
// MP.t = MP_SIZE;
//}
-#define MP_T 55
+#define MP_T 100
void mperr(const char *format, ...) __attribute__((format(printf, 1, 2)));
void mp_gcd(int64_t *, int64_t *);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]