[Python-checkins] r46771 - sandbox/trunk/decimal-c/_decimal.c
mateusz.rukowicz
python-checkins at python.org
Fri Jun 9 13:37:48 CEST 2006
Author: mateusz.rukowicz
Date: Fri Jun 9 13:37:47 2006
New Revision: 46771
Modified:
sandbox/trunk/decimal-c/_decimal.c
Log:
Bug fixed.
Modified: sandbox/trunk/decimal-c/_decimal.c
==============================================================================
--- sandbox/trunk/decimal-c/_decimal.c (original)
+++ sandbox/trunk/decimal-c/_decimal.c Fri Jun 9 13:37:47 2006
@@ -2678,6 +2678,7 @@
long digits_after_dot = 0;
char *p = str;
char *first_digit = 0;
+ char *last_digit = 0;
char *dot = 0;
char *e = 0;
char *c;
@@ -2740,13 +2741,16 @@
zero = 1;
ndigits = 1;
}
- else /* let's count digits */
+ else /* let's count digits and find by the way last digit*/
{
ndigits = 0;
for(c = first_digit; c - str < len; c++)
{
if(isdigit(*c))
+ {
ndigits ++;
+ last_digit = c;
+ }
else
if(*c == 'e' || *c == 'E')
break;
@@ -2773,7 +2777,7 @@
long mult = 1; /* now we just read integer till '\0' or 'e'/'E', dont care about '.' */
long limb = 0;
- for(c = p; c - str < len; c++)
+ for(c = last_digit; c >= first_digit; c--)
{
if(*c == 'e' || *c == 'E') break;
if(!isdigit(*c)) continue;
@@ -2781,6 +2785,7 @@
assert(limb < new->limb_count);
new->limbs[limb] += mult * (*c - '0');
+ mult *= 10;
if(mult == BASE)
{
limb ++;
More information about the Python-checkins
mailing list