summaryrefslogtreecommitdiffstats
path: root/Python/atof.c
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2010-05-09 15:15:40 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2010-05-09 15:15:40 (GMT)
commitc7c96a90bcf1366ac6f350f5506d0afee611e351 (patch)
tree4134c189d25fe972f2717f4b642a26e5f323a922 /Python/atof.c
parentba32864b2d97018c71ce90926c853a67e79becf7 (diff)
downloadcpython-c7c96a90bcf1366ac6f350f5506d0afee611e351.zip
cpython-c7c96a90bcf1366ac6f350f5506d0afee611e351.tar.gz
cpython-c7c96a90bcf1366ac6f350f5506d0afee611e351.tar.bz2
Recorded merge of revisions 81029 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r81029 | antoine.pitrou | 2010-05-09 16:46:46 +0200 (dim., 09 mai 2010) | 3 lines Untabify C files. Will watch buildbots. ........
Diffstat (limited to 'Python/atof.c')
-rw-r--r--Python/atof.c74
1 files changed, 37 insertions, 37 deletions
diff --git a/Python/atof.c b/Python/atof.c
index 8fbde38..562fcd6 100644
--- a/Python/atof.c
+++ b/Python/atof.c
@@ -10,41 +10,41 @@
double atof(char *s)
{
- double a = 0.0;
- int e = 0;
- int c;
- while ((c = *s++) != '\0' && isdigit(c)) {
- a = a*10.0 + (c - '0');
- }
- if (c == '.') {
- while ((c = *s++) != '\0' && isdigit(c)) {
- a = a*10.0 + (c - '0');
- e = e-1;
- }
- }
- if (c == 'e' || c == 'E') {
- int sign = 1;
- int i = 0;
- c = *s++;
- if (c == '+')
- c = *s++;
- else if (c == '-') {
- c = *s++;
- sign = -1;
- }
- while (isdigit(c)) {
- i = i*10 + (c - '0');
- c = *s++;
- }
- e += i*sign;
- }
- while (e > 0) {
- a *= 10.0;
- e--;
- }
- while (e < 0) {
- a *= 0.1;
- e++;
- }
- return a;
+ double a = 0.0;
+ int e = 0;
+ int c;
+ while ((c = *s++) != '\0' && isdigit(c)) {
+ a = a*10.0 + (c - '0');
+ }
+ if (c == '.') {
+ while ((c = *s++) != '\0' && isdigit(c)) {
+ a = a*10.0 + (c - '0');
+ e = e-1;
+ }
+ }
+ if (c == 'e' || c == 'E') {
+ int sign = 1;
+ int i = 0;
+ c = *s++;
+ if (c == '+')
+ c = *s++;
+ else if (c == '-') {
+ c = *s++;
+ sign = -1;
+ }
+ while (isdigit(c)) {
+ i = i*10 + (c - '0');
+ c = *s++;
+ }
+ e += i*sign;
+ }
+ while (e > 0) {
+ a *= 10.0;
+ e--;
+ }
+ while (e < 0) {
+ a *= 0.1;
+ e++;
+ }
+ return a;
}