[gcalctool] Support user chosen default base
- From: Robert Ancell <rancell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gcalctool] Support user chosen default base
- Date: Mon, 12 Apr 2010 14:16:47 +0000 (UTC)
commit 2f613a422518a2e5970133e3ff9a9ff718d0fe2a
Author: Robert Ancell <robert ancell gmail com>
Date: Mon Apr 12 22:16:30 2010 +0800
Support user chosen default base
data/preferences.ui | 1 +
src/calctool.c | 3 +-
src/currency.c | 2 +-
src/gcalccmd.c | 3 +-
src/math-buttons.c | 4 +-
src/math-equation.c | 19 ++++++++-------
src/math-preferences.c | 21 +++++++++++++++--
src/mp-binary.c | 18 +++++++-------
src/mp-convert.c | 40 ++++++++++++++++----------------
src/mp-equation-lexer.l | 6 ++--
src/mp-equation.c | 4 +-
src/mp-equation.h | 3 ++
src/mp-trigonometric.c | 2 +-
src/mp.h | 4 +-
src/register.c | 4 +-
src/unittest.c | 56 +++++++++++++++++++++++-----------------------
16 files changed, 106 insertions(+), 84 deletions(-)
---
diff --git a/data/preferences.ui b/data/preferences.ui
index ff7f736..3a8ee02 100644
--- a/data/preferences.ui
+++ b/data/preferences.ui
@@ -251,6 +251,7 @@
<object class="GtkComboBox" id="number_base_combobox">
<property name="visible">True</property>
<property name="model">number_base_model</property>
+ <signal name="changed" handler="number_base_combobox_changed_cb"/>
</object>
<packing>
<property name="left_attach">1</property>
diff --git a/src/calctool.c b/src/calctool.c
index 67df778..ad41287 100644
--- a/src/calctool.c
+++ b/src/calctool.c
@@ -48,6 +48,7 @@ solve(const char *equation)
char result_str[1024];
memset(&options, 0, sizeof(options));
+ options.base = 10;
options.wordlen = 32;
options.angle_units = MP_DEGREES;
@@ -61,7 +62,7 @@ solve(const char *equation)
exit(1);
}
else {
- mp_cast_to_string(&result, 10, 9, 1, result_str, 1024);
+ mp_cast_to_string(&result, 10, 10, 9, 1, result_str, 1024);
printf("%s\n", result_str);
exit(0);
}
diff --git a/src/currency.c b/src/currency.c
index e78da52..3d63795 100644
--- a/src/currency.c
+++ b/src/currency.c
@@ -109,7 +109,7 @@ set_rate (xmlNodePtr node, currency *cur)
cur->short_name = (char *)xmlNodeGetContent((xmlNodePtr) attribute);
} else if (strcmp ((char *)attribute->name, "rate") == 0) {
char *val = (char *)xmlNodeGetContent ((xmlNodePtr) attribute);
- mp_set_from_string(val, &(cur->value));
+ mp_set_from_string(val, 10, &(cur->value));
xmlFree (val);
}
}
diff --git a/src/gcalccmd.c b/src/gcalccmd.c
index 64f3330..95fcc31 100644
--- a/src/gcalccmd.c
+++ b/src/gcalccmd.c
@@ -37,6 +37,7 @@ solve(const char *equation)
char result_str[MAXLINE];
memset(&options, 0, sizeof(options));
+ options.base = 10;
options.wordlen = 32;
options.angle_units = MP_DEGREES;
@@ -47,7 +48,7 @@ solve(const char *equation)
else if (ret)
fprintf(stderr, "Error %d\n", ret);
else {
- mp_cast_to_string(&z, 10, 9, 1, result_str, MAXLINE);
+ mp_cast_to_string(&z, 10, 10, 9, 1, result_str, MAXLINE);
printf("%s\n", result_str);
}
}
diff --git a/src/math-buttons.c b/src/math-buttons.c
index 9b92c0c..f09a1bb 100644
--- a/src/math-buttons.c
+++ b/src/math-buttons.c
@@ -851,7 +851,7 @@ finc_response_cb(GtkWidget *widget, gint response_id, MathButtons *buttons)
continue;
}
entry = GET_WIDGET(buttons->priv->financial_ui, finc_dialog_fields[dialog][i]);
- mp_set_from_string(gtk_entry_get_text(GTK_ENTRY(entry)), &arg[i]);
+ mp_set_from_string(gtk_entry_get_text(GTK_ENTRY(entry)), 10, &arg[i]);
gtk_entry_set_text(GTK_ENTRY(entry), "0");
}
gtk_widget_grab_focus(GET_WIDGET(buttons->priv->financial_ui, finc_dialog_fields[dialog][0]));
@@ -989,7 +989,7 @@ currency_cb(GtkWidget *widget, MathButtons *buttons)
gchar *result;
result = g_strdup_printf("%.2f", gtk_spin_button_get_value(c_amount_lower));
- mp_set_from_string(result, &display_val);
+ mp_set_from_string(result, 10, &display_val);
g_free(result);
math_equation_set_number(buttons->priv->equation, &display_val);
diff --git a/src/math-equation.c b/src/math-equation.c
index 048ca5f..4e07f8c 100644
--- a/src/math-equation.c
+++ b/src/math-equation.c
@@ -380,7 +380,7 @@ math_equation_get_number(MathEquation *equation, MPNumber *z)
gboolean result;
text = math_equation_get_display(equation);
- result = !mp_set_from_string(text, z);
+ result = !mp_set_from_string(text, equation->priv->base, z);
g_free (text);
return result;
@@ -726,6 +726,7 @@ parse(MathEquation *equation, const char *text, MPNumber *z, char **error_token)
MPEquationOptions options;
memset(&options, 0, sizeof(options));
+ options.base = equation->priv->base;
options.wordlen = equation->priv->word_size;
options.angle_units = equation->priv->angle_units;
options.variable_is_defined = variable_is_defined;
@@ -963,7 +964,7 @@ display_get_integer(MathEquation *equation, gint64 *value)
/* Convert engineering or scientific number in the given base. */
// FIXME: Move into mp-convert.c
static void
-make_eng_sci(MathEquation *equation, char *target, int target_len, const MPNumber *x, int base_)
+make_eng_sci(MathEquation *equation, char *target, int target_len, const MPNumber *x, int default_base, int base_)
{
char fixed[MAX_DIGITS], *c;
MPNumber t, z, base, base3, base10, base10inv, mantissa;
@@ -1010,7 +1011,7 @@ make_eng_sci(MathEquation *equation, char *target, int target_len, const MPNumbe
}
}
- mp_cast_to_string(&mantissa, base_, equation->priv->accuracy, !equation->priv->show_zeroes, fixed, MAX_DIGITS);
+ mp_cast_to_string(&mantissa, default_base, base_, equation->priv->accuracy, !equation->priv->show_zeroes, fixed, MAX_DIGITS);
g_string_append(string, fixed);
g_string_append_printf(string, "Ã?10");
if (exponent < 0) {
@@ -1033,22 +1034,22 @@ display_make_number(MathEquation *equation, char *target, int target_len, const
{
switch(equation->priv->format) {
case DEC:
- mp_cast_to_string(x, 10, equation->priv->accuracy, !equation->priv->show_zeroes, target, target_len);
+ mp_cast_to_string(x, equation->priv->base, 10, equation->priv->accuracy, !equation->priv->show_zeroes, target, target_len);
break;
case BIN:
- mp_cast_to_string(x, 2, equation->priv->accuracy, !equation->priv->show_zeroes, target, target_len);
+ mp_cast_to_string(x, equation->priv->base, 2, equation->priv->accuracy, !equation->priv->show_zeroes, target, target_len);
break;
case OCT:
- mp_cast_to_string(x, 8, equation->priv->accuracy, !equation->priv->show_zeroes, target, target_len);
+ mp_cast_to_string(x, equation->priv->base, 8, equation->priv->accuracy, !equation->priv->show_zeroes, target, target_len);
break;
case HEX:
- mp_cast_to_string(x, 16, equation->priv->accuracy, !equation->priv->show_zeroes, target, target_len);
+ mp_cast_to_string(x, equation->priv->base, 16, equation->priv->accuracy, !equation->priv->show_zeroes, target, target_len);
break;
case SCI:
- make_eng_sci(equation, target, target_len, x, 10);
+ make_eng_sci(equation, target, target_len, x, equation->priv->base, 10);
break;
case ENG:
- make_eng_sci(equation, target, target_len, x, 10);
+ make_eng_sci(equation, target, target_len, x, equation->priv->base, 10);
break;
}
}
diff --git a/src/math-preferences.c b/src/math-preferences.c
index 37964f5..cb49dec 100644
--- a/src/math-preferences.c
+++ b/src/math-preferences.c
@@ -63,6 +63,21 @@ preferences_dialog_delete_cb(GtkWidget *widget, GdkEvent *event)
G_MODULE_EXPORT
void
+display_format_combobox_changed_cb(GtkWidget *combo, MathPreferencesDialog *dialog)
+{
+ DisplayFormat value;
+ GtkTreeModel *model;
+ GtkTreeIter iter;
+
+ model = gtk_combo_box_get_model(GTK_COMBO_BOX(combo));
+ gtk_combo_box_get_active_iter(GTK_COMBO_BOX(combo), &iter);
+ gtk_tree_model_get(model, &iter, 1, &value, -1);
+ math_equation_set_display_format(dialog->priv->equation, value);
+}
+
+
+G_MODULE_EXPORT
+void
angle_unit_combobox_changed_cb(GtkWidget *combo, MathPreferencesDialog *dialog)
{
MPAngleUnit value;
@@ -78,16 +93,16 @@ angle_unit_combobox_changed_cb(GtkWidget *combo, MathPreferencesDialog *dialog)
G_MODULE_EXPORT
void
-display_format_combobox_changed_cb(GtkWidget *combo, MathPreferencesDialog *dialog)
+number_base_combobox_changed_cb(GtkWidget *combo, MathPreferencesDialog *dialog)
{
- DisplayFormat value;
+ MPAngleUnit value;
GtkTreeModel *model;
GtkTreeIter iter;
model = gtk_combo_box_get_model(GTK_COMBO_BOX(combo));
gtk_combo_box_get_active_iter(GTK_COMBO_BOX(combo), &iter);
gtk_tree_model_get(model, &iter, 1, &value, -1);
- math_equation_set_display_format(dialog->priv->equation, value);
+ math_equation_set_base(dialog->priv->equation, value);
}
diff --git a/src/mp-binary.c b/src/mp-binary.c
index ed9dfa2..4f75e40 100644
--- a/src/mp-binary.c
+++ b/src/mp-binary.c
@@ -45,10 +45,10 @@ mp_bitwise(const MPNumber *x, const MPNumber *y, int (*bitwise_operator)(int, in
char text1[MAX_DIGITS], text2[MAX_DIGITS], text_out[MAX_DIGITS], text_out2[MAX_DIGITS];
int offset1, offset2, offset_out;
- mp_cast_to_string(x, 16, 0, 0, text1, MAX_DIGITS);
- mp_cast_to_string(y, 16, 0, 0, text2, MAX_DIGITS);
- offset1 = strlen(text1) - 1 - strlen("â??â??");
- offset2 = strlen(text2) - 1 - strlen("â??â??");
+ mp_cast_to_string(x, 16, 16, 0, 0, text1, MAX_DIGITS);
+ mp_cast_to_string(y, 16, 16, 0, 0, text2, MAX_DIGITS);
+ offset1 = strlen(text1) - 1;
+ offset2 = strlen(text2) - 1;
offset_out = wordlen / 4 - 1;
if (offset_out <= 0) {
offset_out = offset1 > offset2 ? offset1 : offset2;
@@ -73,8 +73,8 @@ mp_bitwise(const MPNumber *x, const MPNumber *y, int (*bitwise_operator)(int, in
text_out[offset_out] = digits[bitwise_operator(v1, v2)];
}
- snprintf(text_out2, MAX_DIGITS, "%sâ??â??", text_out);
- mp_set_from_string(text_out2, z);
+ snprintf(text_out2, MAX_DIGITS, "%s", text_out);
+ mp_set_from_string(text_out2, 16, z);
}
@@ -156,11 +156,11 @@ mp_mask(const MPNumber *x, int wordlen, MPNumber *z)
size_t len, offset;
/* Convert to a hexadecimal string and use last characters */
- mp_cast_to_string(x, 16, 0, 0, text, MAX_DIGITS);
- len = strlen(text) - strlen("â??â??");
+ mp_cast_to_string(x, 16, 16, 0, 0, text, MAX_DIGITS);
+ len = strlen(text);
offset = wordlen / 4;
offset = len > offset ? len - offset: 0;
- mp_set_from_string(text + offset, z);
+ mp_set_from_string(text + offset, 16, z);
}
diff --git a/src/mp-convert.c b/src/mp-convert.c
index 575b1c4..2013be1 100644
--- a/src/mp-convert.c
+++ b/src/mp-convert.c
@@ -503,7 +503,7 @@ mp_cast_to_double(const MPNumber *x)
static void
-mp_cast_to_string_real(const MPNumber *x, int base, int accuracy, bool trim_zeroes, bool force_sign, GString *string)
+mp_cast_to_string_real(const MPNumber *x, int default_base, int base, int accuracy, bool trim_zeroes, bool force_sign, GString *string)
{
static char digits[] = "0123456789ABCDEF";
MPNumber number, integer_component, fractional_component, temp;
@@ -574,26 +574,26 @@ mp_cast_to_string_real(const MPNumber *x, int base, int accuracy, bool trim_zero
g_string_prepend(string, "+");
}
- switch(base)
- {
- case 2:
- g_string_append(string, "â??");
- break;
- case 8:
- g_string_append(string, "â??");
- break;
- default:
- case 10:
- break;
- case 16:
- g_string_append(string, "â??â??");
- break;
+ /* Append base suffix if not in default base */
+ if (base != default_base) {
+ const char *digits[] = {"â??", "â??", "â??", "â??", "â??", "â??", "â??", "â??", "â??", "â??"};
+ int multiplier = 1;
+ int b = base;
+
+ while (base / multiplier != 0)
+ multiplier *= 10;
+ while (multiplier != 1) {
+ int d = b / multiplier;
+ g_string_append(string, digits[d]);
+ b -= d * multiplier;
+ multiplier /= 10;
+ }
}
}
void
-mp_cast_to_string(const MPNumber *x, int base, int accuracy, bool trim_zeroes, char *buffer, int buffer_length)
+mp_cast_to_string(const MPNumber *x, int default_base, int base, int accuracy, bool trim_zeroes, char *buffer, int buffer_length)
{
MPNumber x_real, x_im;
GString *string;
@@ -603,7 +603,7 @@ mp_cast_to_string(const MPNumber *x, int base, int accuracy, bool trim_zeroes, c
mp_real_component(x, &x_real);
mp_imaginary_component(x, &x_im);
- mp_cast_to_string_real(&x_real, base, accuracy, trim_zeroes, FALSE, string);
+ mp_cast_to_string_real(&x_real, default_base, base, accuracy, trim_zeroes, FALSE, string);
if (mp_is_complex(x)) {
GString *s;
gboolean force_sign = TRUE;
@@ -614,7 +614,7 @@ mp_cast_to_string(const MPNumber *x, int base, int accuracy, bool trim_zeroes, c
}
s = g_string_sized_new(buffer_length);
- mp_cast_to_string_real(&x_im, 10, accuracy, trim_zeroes, force_sign, s);
+ mp_cast_to_string_real(&x_im, default_base, 10, accuracy, trim_zeroes, force_sign, s);
if (strcmp(s->str, "1") == 0) {
g_string_append(string, "i");
}
@@ -718,7 +718,7 @@ ends_with(const char *start, const char *end, const char *word)
bool
-mp_set_from_string(const char *str, MPNumber *z)
+mp_set_from_string(const char *str, int default_base, MPNumber *z)
{
int i, base, negate = 0, multiplier = 0, base_multiplier = 1;
const char *c, *end;
@@ -747,7 +747,7 @@ mp_set_from_string(const char *str, MPNumber *z)
break;
}
if (base_multiplier == 1)
- base = 10;
+ base = default_base;
/* Check if this has a sign */
c = str;
diff --git a/src/mp-equation-lexer.l b/src/mp-equation-lexer.l
index 2dd5229..497a926 100644
--- a/src/mp-equation-lexer.l
+++ b/src/mp-equation-lexer.l
@@ -60,10 +60,10 @@ SUP_NUM {SUPER_DIGITS}+
NSUP_NUM {SUPER_MINUS}{SUPER_DIGITS}+
SUB_NUM {SUB_DIGITS}+
WORD {LETTERS}+
-DEC_NUM {DEC}+|{DEC}*{DECIMAL}{DEC}+
+DEF_NUM {HEX}+|{HEX}*{DECIMAL}{HEX}+
BASE_NUM {HEX}+{SUB_NUM}|{HEX}*{DECIMAL}{HEX}+{SUB_NUM}
-NUMBER {DEC_NUM}|{BASE_NUM}|{FRACTION}|{DEC_NUM}{FRACTION}
+NUMBER {DEF_NUM}|{BASE_NUM}|{FRACTION}|{DEC}+{FRACTION}
VARIABLE {WORD}|{WORD}{SUB_NUM}|{GREEKS}
MOD [mM][oO][dD]
@@ -90,7 +90,7 @@ IN [iI][nN]
{OR} {return tOR;}
{XOR} {return tXOR;}
{IN} {return tIN;}
-{NUMBER} {if (mp_set_from_string(yytext, &yylval->int_t) != 0) REJECT; return tNUMBER;}
+{NUMBER} {if (mp_set_from_string(yytext, _mp_equation_get_extra(yyscanner)->options->base, &yylval->int_t) != 0) REJECT; return tNUMBER;}
{SUP_NUM} {yylval->integer = super_atoi(yytext); return tSUPNUM;}
{NSUP_NUM} {yylval->integer = super_atoi(yytext); return tNSUPNUM;}
{SUB_NUM} {yylval->integer = sub_atoi(yytext); return tSUBNUM;}
diff --git a/src/mp-equation.c b/src/mp-equation.c
index 91328f5..8ac80bc 100644
--- a/src/mp-equation.c
+++ b/src/mp-equation.c
@@ -244,8 +244,8 @@ do_convert(const char *units[][2], const MPNumber *x, const char *x_units, const
if (units[z_index][0] == NULL)
return 0;
- mp_set_from_string(units[x_index][1], &x_factor);
- mp_set_from_string(units[z_index][1], &z_factor);
+ mp_set_from_string(units[x_index][1], 10, &x_factor);
+ mp_set_from_string(units[z_index][1], 10, &z_factor);
mp_multiply(x, &x_factor, z);
mp_divide(z, &z_factor, z);
diff --git a/src/mp-equation.h b/src/mp-equation.h
index 5a51f43..faa533a 100644
--- a/src/mp-equation.h
+++ b/src/mp-equation.h
@@ -35,6 +35,9 @@ typedef enum
/* Options for parser */
typedef struct {
+ /* Default number base */
+ int base;
+
/* The wordlength for binary operations in bits (e.g. 8, 16, 32) */
int wordlen;
diff --git a/src/mp-trigonometric.c b/src/mp-trigonometric.c
index 53b8007..95989ad 100644
--- a/src/mp-trigonometric.c
+++ b/src/mp-trigonometric.c
@@ -64,7 +64,7 @@ convert_to_radians(const MPNumber *x, MPAngleUnit unit, MPNumber *z)
void
mp_get_pi(MPNumber *z)
{
- mp_set_from_string("3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679", z);
+ mp_set_from_string("3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679", 10, z);
}
diff --git a/src/mp.h b/src/mp.h
index 9cc8526..38d82ab 100644
--- a/src/mp.h
+++ b/src/mp.h
@@ -242,7 +242,7 @@ void mp_set_from_random(MPNumber *z);
/* Sets z from a string representation in 'text'.
* Returns true on success.
*/
-bool mp_set_from_string(const char *text, MPNumber *z);
+bool mp_set_from_string(const char *text, int default_base, MPNumber *z);
/* Returns x as a native single-precision floating point number */
float mp_cast_to_float(const MPNumber *x);
@@ -263,7 +263,7 @@ uint64_t mp_cast_to_unsigned_int(const MPNumber *x);
* If 'trim_zeroes' is non-zero then strip off trailing zeroes.
* Fractional components are truncated at 'max_digits' digits.
*/
-void mp_cast_to_string(const MPNumber *x, int base, int max_digits, bool trim_zeroes, char *buffer, int buffer_length);
+void mp_cast_to_string(const MPNumber *x, int default_base, int base, int max_digits, bool trim_zeroes, char *buffer, int buffer_length);
/* Sets z = sin x */
void mp_sin(const MPNumber *x, MPAngleUnit unit, MPNumber *z);
diff --git a/src/register.c b/src/register.c
index d3189ac..f7f29d7 100644
--- a/src/register.c
+++ b/src/register.c
@@ -54,7 +54,7 @@ registers_load()
value = g_strstrip(value);
t = g_malloc(sizeof(MPNumber));
- if (mp_set_from_string(value, t) == 0)
+ if (mp_set_from_string(value, 10, t) == 0)
g_hash_table_insert(registers, g_strdup(name), t);
else
g_free(t);
@@ -86,7 +86,7 @@ registers_save()
MPNumber *value = val;
char number[1024];
- mp_cast_to_string(value, 10, 50, TRUE, number, 1024);
+ mp_cast_to_string(value, 10, 10, 50, TRUE, number, 1024);
fprintf(f, "%s=%s\n", name, number);
}
fclose(f);
diff --git a/src/unittest.c b/src/unittest.c
index 766f0f9..7c39ef2 100644
--- a/src/unittest.c
+++ b/src/unittest.c
@@ -25,7 +25,6 @@
#include "mp-equation.h"
static MPEquationOptions options;
-static int base;
static int fails = 0;
@@ -84,7 +83,7 @@ test(char *expression, char *expected, int expected_error)
error = mp_equation_parse(expression, &options, &result, NULL);
if(error == 0) {
- mp_cast_to_string(&result, base, 9, 1, result_str, 1024);
+ mp_cast_to_string(&result, options.base, options.base, 9, 1, result_str, 1024);
if(expected_error != 0)
fail("'%s' -> %s, expected error %s", expression, result_str, error_code_to_string(expected_error));
else if(strcmp(result_str, expected) != 0)
@@ -106,7 +105,7 @@ static void
test_conversions()
{
memset(&options, 0, sizeof(options));
- base = 10;
+ options.base = 10;
options.wordlen = 32;
options.angle_units = MP_DEGREES;
@@ -160,23 +159,24 @@ void
test_equations()
{
memset(&options, 0, sizeof(options));
- base = 10;
+ options.base = 10;
options.wordlen = 32;
options.angle_units = MP_DEGREES;
options.variable_is_defined = variable_is_defined;
options.get_variable = get_variable;
options.set_variable = set_variable;
- base = 2;
- test("2", "10â??", 0);
+ options.base = 2;
+ test("2â??â??", "10", 0);
- base = 8;
- test("16434824", "76543210â??", 0);
+ options.base = 8;
+ test("16434824â??â??", "76543210", 0);
- base = 16;
- test("18364758544493064720", "FEDCBA9876543210â??â??", 0);
+ options.base = 16;
+ test("FF", "FF", 0);
+ test("18364758544493064720â??â??", "FEDCBA9876543210", 0);
- base = 10;
+ options.base = 10;
test("0â??", "0", 0); test("0â??", "0", 0); test("0", "0", 0); test("0â??â??", "0", 0);
test("1â??", "1", 0); test("1â??", "1", 0); test("1", "1", 0); test("1â??â??", "1", 0);
test("2â??", "", PARSER_ERR_INVALID); test("2â??", "2", 0); test("2", "2", 0); test("2â??â??", "2", 0);
@@ -497,24 +497,24 @@ test_equations()
test("1 xor 1", "0", 0);
test("3 xor 5", "6", 0);
- base = 16;
- test("ones 1", "FFFFFFFEâ??â??", 0);
- test("ones 7FFFFFFFâ??â??", "80000000â??â??", 0);
- test("twos 1", "FFFFFFFFâ??â??", 0);
- test("twos 7FFFFFFFâ??â??", "80000001â??â??", 0);
- test("~7Aâ??â??", "FFFFFF85â??â??", 0);
+ options.base = 16;
+ test("ones 1", "FFFFFFFE", 0);
+ test("ones 7FFFFFFF", "80000000", 0);
+ test("twos 1", "FFFFFFFF", 0);
+ test("twos 7FFFFFFF", "80000001", 0);
+ test("~7Aâ??â??", "FFFFFF85", 0);
-/* base = 2;
+ options.base = 2;
options.wordlen = 4;
- test("1100â??â?§1010â??", "1000â??", 0);
- test("1100â??â?¨1010â??", "1110â??", 0);
- test("1100â??â?»1010â??", "110â??", 0);
- test("1100â??â??1010â??", "110â??", 0);
- test("1100â??â?¼1010â??", "0111â??", 0);
- test("1100â??â?½1010â??", "0001â??", 0);
- options.wordlen = 2;
- test("¬10â??", "1â??", 0);
- test("¬¬10â??", "10â??", 0);*/
+ test("1100â?§1010", "1000", 0);
+ test("1100â?¨1010", "1110", 0);
+ test("1100â?»1010", "110", 0);
+ test("1100â??1010", "110", 0);
+ //test("1100â?¼1010", "0111", 0);
+ //test("1100â?½1010", "0001", 0);
+ //options.wordlen = 2;
+ //test("¬01â??", "10â??", 0);
+ //test("¬¬10â??", "10â??", 0);
}
@@ -539,7 +539,7 @@ test_string(const char *number)
{
MPNumber t;
- mp_set_from_string(number, &t);
+ mp_set_from_string(number, 10, &t);
printf("MPNumber(%s) -> {", number);
print_number(&t);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]