gcalctool r2078 - in branches/gnome-2-22: . gcalctool
- From: rancell svn gnome org
- To: svn-commits-list gnome org
- Subject: gcalctool r2078 - in branches/gnome-2-22: . gcalctool
- Date: Sat, 19 Apr 2008 03:44:47 +0100 (BST)
Author: rancell
Date: Sat Apr 19 02:44:47 2008
New Revision: 2078
URL: http://svn.gnome.org/viewvc/gcalctool?rev=2078&view=rev
Log:
Use correct radix when converting numbers to strings (Bug #527669)
Modified:
branches/gnome-2-22/ChangeLog
branches/gnome-2-22/gcalctool/display.c
Modified: branches/gnome-2-22/gcalctool/display.c
==============================================================================
--- branches/gnome-2-22/gcalctool/display.c (original)
+++ branches/gnome-2-22/gcalctool/display.c Sat Apr 19 02:44:47 2008
@@ -186,7 +186,7 @@
int MP1base[MP_SIZE], MP1[MP_SIZE], MP2[MP_SIZE], MPval[MP_SIZE];
int ndig; /* Total number of digits to generate. */
int ddig; /* Number of digits to left of decimal sep. */
- int dval, n;
+ int dval, n, i;
optr = str;
mpabs(MPnumber, MPval);
@@ -221,7 +221,8 @@
while (ndig-- > 0) {
if (ddig-- == 0) {
- *optr++ = '.';
+ for (i = 0; i < strlen(v->radix); i++)
+ *optr++ = v->radix[i];
}
mpmul(MPval, MP1base, MPval);
mpcmi(MPval, &dval);
@@ -240,15 +241,16 @@
}
v->pointed = 0;
- if (!v->show_zeroes && v->accuracy != 0) {
- optr = str + strlen(str) - 1;
- while (*optr == '0') {
- optr--;
+ /* Strip off trailing zeroes */
+ if (!v->show_zeroes) {
+ for (i = strlen(str) - 1; i > 1 && str[i] == '0'; i--) {
+ str[i] = '\0';
+ }
+
+ /* If no fractional part discard radix */
+ if (strlen(str) >= strlen(v->radix) && strcmp(str + strlen(str) - strlen(v->radix), v->radix) == 0) {
+ str[strlen(str) - strlen(v->radix)] = '\0';
}
- if (optr < str || *optr != '.') {
- optr++;
- }
- *optr = '\0';
}
return(str);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]