Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
cfaf79c5
Kaydet (Commit)
cfaf79c5
authored
Eki 26, 2009
tarafından
Eric Smith
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Start to remove _PyOS_double_to_string, as mentioned in issue 7117.
üst
0e0e2153
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
22 deletions
+36
-22
floatobject.c
Objects/floatobject.c
+36
-22
No files found.
Objects/floatobject.c
Dosyayı görüntüle @
cfaf79c5
...
@@ -335,58 +335,72 @@ convert_to_double(PyObject **v, double *dbl)
...
@@ -335,58 +335,72 @@ convert_to_double(PyObject **v, double *dbl)
return
0
;
return
0
;
}
}
/* XXX PyFloat_AsString and PyFloat_AsReprString
should b
e deprecated:
/* XXX PyFloat_AsString and PyFloat_AsReprString
ar
e deprecated:
XXX they pass a char buffer without passing a length.
XXX they pass a char buffer without passing a length.
*/
*/
void
void
PyFloat_AsString
(
char
*
buf
,
PyFloatObject
*
v
)
PyFloat_AsString
(
char
*
buf
,
PyFloatObject
*
v
)
{
{
_PyOS_double_to_string
(
buf
,
100
,
v
->
ob_fval
,
'g'
,
PyFloat_STR_PRECISION
,
char
*
tmp
=
PyOS_double_to_string
(
v
->
ob_fval
,
'g'
,
Py_DTSF_ADD_DOT_0
,
NULL
);
PyFloat_STR_PRECISION
,
Py_DTSF_ADD_DOT_0
,
NULL
);
strcpy
(
buf
,
tmp
);
PyMem_Free
(
tmp
);
}
}
void
void
PyFloat_AsReprString
(
char
*
buf
,
PyFloatObject
*
v
)
PyFloat_AsReprString
(
char
*
buf
,
PyFloatObject
*
v
)
{
{
_PyOS_double_to_string
(
buf
,
100
,
v
->
ob_fval
,
'r'
,
0
,
char
*
tmp
=
PyOS_double_to_string
(
v
->
ob_fval
,
'r'
,
0
,
Py_DTSF_ADD_DOT_0
,
NULL
);
Py_DTSF_ADD_DOT_0
,
NULL
);
strcpy
(
buf
,
tmp
);
PyMem_Free
(
tmp
);
}
}
/* ARGSUSED */
/* ARGSUSED */
static
int
static
int
float_print
(
PyFloatObject
*
v
,
FILE
*
fp
,
int
flags
)
float_print
(
PyFloatObject
*
v
,
FILE
*
fp
,
int
flags
)
{
{
char
buf
[
100
]
;
char
*
buf
;
if
(
flags
&
Py_PRINT_RAW
)
if
(
flags
&
Py_PRINT_RAW
)
_PyOS_double_to_string
(
buf
,
sizeof
(
buf
),
v
->
ob_fval
,
buf
=
PyOS_double_to_string
(
v
->
ob_fval
,
'g'
,
PyFloat_STR_PRECISION
,
'g'
,
PyFloat_STR_PRECISION
,
Py_DTSF_ADD_DOT_0
,
NULL
);
Py_DTSF_ADD_DOT_0
,
NULL
);
else
else
_PyOS_double_to_string
(
buf
,
sizeof
(
buf
),
v
->
ob_fval
,
buf
=
PyOS_double_to_string
(
v
->
ob_fval
,
'r'
,
0
,
Py_DTSF_ADD_DOT_0
,
NULL
);
'r'
,
0
,
Py_DTSF_ADD_DOT_0
,
NULL
);
Py_BEGIN_ALLOW_THREADS
Py_BEGIN_ALLOW_THREADS
fputs
(
buf
,
fp
);
fputs
(
buf
,
fp
);
Py_END_ALLOW_THREADS
Py_END_ALLOW_THREADS
PyMem_Free
(
buf
);
return
0
;
return
0
;
}
}
static
PyObject
*
float_str_or_repr
(
PyFloatObject
*
v
,
int
precision
,
char
format_code
)
{
PyObject
*
result
;
char
*
buf
=
PyOS_double_to_string
(
PyFloat_AS_DOUBLE
(
v
),
format_code
,
precision
,
Py_DTSF_ADD_DOT_0
,
NULL
);
if
(
!
buf
)
return
PyErr_NoMemory
();
result
=
PyString_FromString
(
buf
);
PyMem_Free
(
buf
);
return
result
;
}
static
PyObject
*
static
PyObject
*
float_repr
(
PyFloatObject
*
v
)
float_repr
(
PyFloatObject
*
v
)
{
{
char
buf
[
100
];
return
float_str_or_repr
(
v
,
0
,
'r'
);
_PyOS_double_to_string
(
buf
,
sizeof
(
buf
),
v
->
ob_fval
,
'r'
,
0
,
Py_DTSF_ADD_DOT_0
,
NULL
);
return
PyString_FromString
(
buf
);
}
}
static
PyObject
*
static
PyObject
*
float_str
(
PyFloatObject
*
v
)
float_str
(
PyFloatObject
*
v
)
{
{
char
buf
[
100
];
return
float_str_or_repr
(
v
,
PyFloat_STR_PRECISION
,
'g'
);
_PyOS_double_to_string
(
buf
,
sizeof
(
buf
),
v
->
ob_fval
,
'g'
,
PyFloat_STR_PRECISION
,
Py_DTSF_ADD_DOT_0
,
NULL
);
return
PyString_FromString
(
buf
);
}
}
/* Comparison is pretty much a nightmare. When comparing float to float,
/* Comparison is pretty much a nightmare. When comparing float to float,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment