Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
5c960b8c
Commit
5c960b8c
authored
Jun 24, 2008
by
Raymond Hettinger
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert 64451.
parent
11c1a332
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
1 addition
and
63 deletions
+1
-63
Include/floatobject.h
Include/floatobject.h
+0
-2
Lib/test/test_builtin.py
Lib/test/test_builtin.py
+0
-27
Objects/abstract.c
Objects/abstract.c
+1
-4
Objects/floatobject.c
Objects/floatobject.c
+0
-30
No files found.
Include/floatobject.h
View file @
5c960b8c
...
@@ -111,8 +111,6 @@ PyAPI_FUNC(PyObject *) _PyFloat_FormatAdvanced(PyObject *obj,
...
@@ -111,8 +111,6 @@ PyAPI_FUNC(PyObject *) _PyFloat_FormatAdvanced(PyObject *obj,
Py_UNICODE
*
format_spec
,
Py_UNICODE
*
format_spec
,
Py_ssize_t
format_spec_len
);
Py_ssize_t
format_spec_len
);
PyAPI_FUNC
(
PyObject
*
)
_float_to_base
(
PyObject
*
v
,
int
base
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
#endif
#endif
...
...
Lib/test/test_builtin.py
View file @
5c960b8c
...
@@ -553,15 +553,6 @@ class BuiltinTest(unittest.TestCase):
...
@@ -553,15 +553,6 @@ class BuiltinTest(unittest.TestCase):
self
.
assertEqual
(
hex
(
-
16
),
'-0x10'
)
self
.
assertEqual
(
hex
(
-
16
),
'-0x10'
)
self
.
assertEqual
(
hex
(
-
16
),
'-0x10'
)
self
.
assertEqual
(
hex
(
-
16
),
'-0x10'
)
self
.
assertRaises
(
TypeError
,
hex
,
{})
self
.
assertRaises
(
TypeError
,
hex
,
{})
self
.
assertEqual
(
hex
(
3.125
),
'0x19 * 2.0 ** -3'
)
self
.
assertEqual
(
hex
(
0.0
),
'0x0 * 2.0 ** 0'
)
for
sv
in
float
(
'nan'
),
float
(
'inf'
),
float
(
'-inf'
):
self
.
assertEqual
(
hex
(
sv
),
repr
(
sv
))
for
i
in
range
(
100
):
x
=
random
.
expovariate
(.
05
)
self
.
assertEqual
(
eval
(
hex
(
x
)),
x
,
(
x
,
hex
(
x
),
eval
(
hex
(
x
))))
self
.
assertEqual
(
eval
(
hex
(
-
x
)),
-
x
)
self
.
assertEqual
(
hex
(
-
x
),
(
'-'
+
hex
(
x
)))
def
test_id
(
self
):
def
test_id
(
self
):
id
(
None
)
id
(
None
)
...
@@ -805,15 +796,6 @@ class BuiltinTest(unittest.TestCase):
...
@@ -805,15 +796,6 @@ class BuiltinTest(unittest.TestCase):
self
.
assertEqual
(
oct
(
-
100
),
'-0o144'
)
self
.
assertEqual
(
oct
(
-
100
),
'-0o144'
)
self
.
assertEqual
(
oct
(
-
100
),
'-0o144'
)
self
.
assertEqual
(
oct
(
-
100
),
'-0o144'
)
self
.
assertRaises
(
TypeError
,
oct
,
())
self
.
assertRaises
(
TypeError
,
oct
,
())
self
.
assertEqual
(
oct
(
3.125
),
'0o31 * 2.0 ** -3'
)
self
.
assertEqual
(
oct
(
0.0
),
'0o0 * 2.0 ** 0'
)
for
sv
in
float
(
'nan'
),
float
(
'inf'
),
float
(
'-inf'
):
self
.
assertEqual
(
oct
(
sv
),
repr
(
sv
))
for
i
in
range
(
100
):
x
=
random
.
expovariate
(.
05
)
self
.
assertEqual
(
eval
(
oct
(
x
)),
x
)
self
.
assertEqual
(
eval
(
oct
(
-
x
)),
-
x
)
self
.
assertEqual
(
oct
(
-
x
),
(
'-'
+
oct
(
x
)))
def
write_testfile
(
self
):
def
write_testfile
(
self
):
# NB the first 4 lines are also used to test input, below
# NB the first 4 lines are also used to test input, below
...
@@ -1231,15 +1213,6 @@ class BuiltinTest(unittest.TestCase):
...
@@ -1231,15 +1213,6 @@ class BuiltinTest(unittest.TestCase):
self
.
assertEqual
(
bin
(
2
**
65
-
1
),
'0b'
+
'1'
*
65
)
self
.
assertEqual
(
bin
(
2
**
65
-
1
),
'0b'
+
'1'
*
65
)
self
.
assertEqual
(
bin
(
-
(
2
**
65
)),
'-0b1'
+
'0'
*
65
)
self
.
assertEqual
(
bin
(
-
(
2
**
65
)),
'-0b1'
+
'0'
*
65
)
self
.
assertEqual
(
bin
(
-
(
2
**
65
-
1
)),
'-0b'
+
'1'
*
65
)
self
.
assertEqual
(
bin
(
-
(
2
**
65
-
1
)),
'-0b'
+
'1'
*
65
)
self
.
assertEqual
(
bin
(
3.125
),
'0b11001 * 2.0 ** -3'
)
self
.
assertEqual
(
bin
(
0.0
),
'0b0 * 2.0 ** 0'
)
for
sv
in
float
(
'nan'
),
float
(
'inf'
),
float
(
'-inf'
):
self
.
assertEqual
(
bin
(
sv
),
repr
(
sv
))
for
i
in
range
(
100
):
x
=
random
.
expovariate
(.
05
)
self
.
assertEqual
(
eval
(
bin
(
x
)),
x
)
self
.
assertEqual
(
eval
(
bin
(
-
x
)),
-
x
)
self
.
assertEqual
(
bin
(
-
x
),
(
'-'
+
bin
(
x
)))
class
TestSorted
(
unittest
.
TestCase
):
class
TestSorted
(
unittest
.
TestCase
):
...
...
Objects/abstract.c
View file @
5c960b8c
...
@@ -1451,11 +1451,8 @@ PyObject *
...
@@ -1451,11 +1451,8 @@ PyObject *
PyNumber_ToBase
(
PyObject
*
n
,
int
base
)
PyNumber_ToBase
(
PyObject
*
n
,
int
base
)
{
{
PyObject
*
res
=
NULL
;
PyObject
*
res
=
NULL
;
PyObject
*
index
;
PyObject
*
index
=
PyNumber_Index
(
n
)
;
if
(
PyFloat_Check
(
n
))
return
_float_to_base
(
n
,
base
);
index
=
PyNumber_Index
(
n
);
if
(
!
index
)
if
(
!
index
)
return
NULL
;
return
NULL
;
if
(
PyLong_Check
(
index
))
if
(
PyLong_Check
(
index
))
...
...
Objects/floatobject.c
View file @
5c960b8c
...
@@ -1113,36 +1113,6 @@ PyDoc_STRVAR(float_as_integer_ratio_doc,
...
@@ -1113,36 +1113,6 @@ PyDoc_STRVAR(float_as_integer_ratio_doc,
">>> (-.25).as_integer_ratio()
\n
"
">>> (-.25).as_integer_ratio()
\n
"
"(-1, 4)"
);
"(-1, 4)"
);
PyObject
*
_float_to_base
(
PyObject
*
v
,
int
base
)
{
PyObject
*
mant
,
*
conv
,
*
result
;
double
x
,
fr
;
int
i
,
exp
;
if
(
!
PyFloat_Check
(
v
))
{
PyErr_BadInternalCall
();
return
NULL
;
}
CONVERT_TO_DOUBLE
(
v
,
x
);
if
(
!
Py_IS_FINITE
(
x
))
return
PyObject_Repr
(
v
);
fr
=
frexp
(
x
,
&
exp
);
for
(
i
=
0
;
i
<
300
&&
fr
!=
floor
(
fr
)
;
i
++
)
{
fr
*=
2
.
0
;
exp
--
;
}
mant
=
PyLong_FromDouble
(
floor
(
fr
));
if
(
mant
==
NULL
)
return
NULL
;
conv
=
PyNumber_ToBase
(
mant
,
base
);
Py_DECREF
(
mant
);
if
(
conv
==
NULL
)
return
NULL
;
result
=
PyUnicode_FromFormat
(
"%U * 2.0 ** %d"
,
conv
,
exp
);
Py_DECREF
(
conv
);
return
result
;
}
static
PyObject
*
static
PyObject
*
float_subtype_new
(
PyTypeObject
*
type
,
PyObject
*
args
,
PyObject
*
kwds
);
float_subtype_new
(
PyTypeObject
*
type
,
PyObject
*
args
,
PyObject
*
kwds
);
...
...
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