Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
micropython
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
card10
micropython
Commits
2c756654
Commit
2c756654
authored
Dec 31, 2014
by
Paul Sokolovsky
Browse files
Options
Downloads
Patches
Plain Diff
objstr: Fix %d-formatting of floats.
parent
8a2cc1c7
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
py/objstr.c
+1
-5
1 addition, 5 deletions
py/objstr.c
tests/float/float2int.py
+5
-0
5 additions, 0 deletions
tests/float/float2int.py
with
6 additions
and
5 deletions
py/objstr.c
+
1
−
5
View file @
2c756654
...
@@ -827,11 +827,7 @@ static bool arg_looks_numeric(mp_obj_t arg) {
...
@@ -827,11 +827,7 @@ static bool arg_looks_numeric(mp_obj_t arg) {
static
mp_obj_t
arg_as_int
(
mp_obj_t
arg
)
{
static
mp_obj_t
arg_as_int
(
mp_obj_t
arg
)
{
#if MICROPY_PY_BUILTINS_FLOAT
#if MICROPY_PY_BUILTINS_FLOAT
if
(
MP_OBJ_IS_TYPE
(
arg
,
&
mp_type_float
))
{
if
(
MP_OBJ_IS_TYPE
(
arg
,
&
mp_type_float
))
{
return
mp_obj_new_int_from_float
(
mp_obj_get_float
(
arg
));
// TODO: Needs a way to construct an mpz integer from a float
mp_int_t
num
=
mp_obj_get_float
(
arg
);
return
MP_OBJ_NEW_SMALL_INT
(
num
);
}
}
#endif
#endif
return
arg
;
return
arg
;
...
...
This diff is collapsed.
Click to expand it.
tests/float/float2int.py
+
5
−
0
View file @
2c756654
...
@@ -3,3 +3,8 @@ print(int(1418774543.))
...
@@ -3,3 +3,8 @@ print(int(1418774543.))
# TODO: General case with large exponent
# TODO: General case with large exponent
#print(int(2.**100))
#print(int(2.**100))
print
(
"
%d
"
%
1418774543.
)
# TODO: General case with large exponent
#print("%d" % 2.**100)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment