Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

repr for floats is inconsistent with CPython #102

Open
slide opened this issue Jun 9, 2017 · 3 comments
Open

repr for floats is inconsistent with CPython #102

slide opened this issue Jun 9, 2017 · 3 comments

Comments

@slide
Copy link
Contributor

slide commented Jun 9, 2017

From @slozier on January 11, 2016 21:6

Under CPython (2.7.x), repr of a float returns the shortest string representation which round-trips back to the value. With IronPython, repr returns the representation with 17 digits of precision (which was how CPython did it in 2.6.x).

The function of interest is __repr__ in IronPython\Runtime\Operations\FloatOps.cs.

CPython:

>>> repr(0.1)
'0.1'
>>> repr(0.3)
'0.3'
>>> repr(0.8455124082255701)
'0.8455124082255701'

IronPython:

>>> repr(0.1)
'0.10000000000000001'
>>> repr(0.3)
'0.29999999999999999'
>>> repr(0.8455124082255701)
'0.84551240822557006'

Copied from original issue: IronLanguages/main#1271

@slide
Copy link
Contributor Author

slide commented Jun 9, 2017

From @simplicbe on January 11, 2016 21:53

This should be fixed very easily. Should a test case be added or changed for this?

@slide
Copy link
Contributor Author

slide commented Jun 9, 2017

I thought there was already an issue for this.

@slide
Copy link
Contributor Author

slide commented Jun 9, 2017

From @slozier on January 11, 2016 22:42

I also assumed there would already be an issue for this but I had no luck finding it...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants