Title: Implement remaining string format codes for floats · Issue #1656 · RustPython/RustPython · GitHub
Open Graph Title: Implement remaining string format codes for floats · Issue #1656 · RustPython/RustPython
X Title: Implement remaining string format codes for floats · Issue #1656 · RustPython/RustPython
Description: Feature Implement the g, G, e, E, n, and % format codes for floats. g G e E n % A few examples from CPython: >>> '{:g}'.format(10.0) '10' >>> '{:.1g}'.format(10.0) '1e+01' >>> '{:e}'.format(10.0) '1.000000e+01' >>> '{:.1e}'.format(10.0) ...
Open Graph Description: Feature Implement the g, G, e, E, n, and % format codes for floats. g G e E n % A few examples from CPython: >>> '{:g}'.format(10.0) '10' >>> '{:.1g}'.format(10.0) '1e+01' >>> '{:e}'.format(10.0) '...
X Description: Feature Implement the g, G, e, E, n, and % format codes for floats. g G e E n % A few examples from CPython: >>> '{:g}'.format(10.0) '10' >>> '{:.1g}'.form...
Opengraph URL: https://github.com/RustPython/RustPython/issues/1656
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Implement remaining string format codes for floats","articleBody":"## Feature\r\n\r\nImplement the `g`, `G`, `e`, `E`, `n`, and `%` format codes for floats.\r\n\r\n- [x] g\r\n- [x] G\r\n- [x] e\r\n- [x] E\r\n- [x] n\r\n- [x] %\r\n\r\n## A few examples from CPython:\r\n```Python\r\n\u003e\u003e\u003e '{:g}'.format(10.0)\r\n'10'\r\n\u003e\u003e\u003e '{:.1g}'.format(10.0)\r\n'1e+01'\r\n\u003e\u003e\u003e '{:e}'.format(10.0)\r\n'1.000000e+01'\r\n\u003e\u003e\u003e '{:.1e}'.format(10.0)\r\n'1.0e+01'\r\n\u003e\u003e\u003e '{:n}'.format(999999.1234)\r\n'999999'\r\n\u003e\u003e\u003e '{:n}'.format(1000000.1234)\r\n'1e+06'\r\n\u003e\u003e\u003e '{:.8n}'.format(1000000.1234)\r\n'1000000.1'\r\n\u003e\u003e\u003e '{:.11n}'.format(1000000.1234)\r\n'1000000.1234'\r\n\u003e\u003e\u003e '{:%}'.format(10.0)\r\n'1000.000000%'\r\n```\r\n## RustPython\r\n```Python\r\n\u003e\u003e\u003e\u003e\u003e '{:g}'.format(10.0)\r\nTraceback (most recent call last):\r\n File \"\u003cstdin\u003e\", line 1, in \u003cmodule\u003e\r\nValueError: Format code 'g' for object of type 'float' not implemented yet\r\n\u003e\u003e\u003e\u003e\u003e '{:G}'.format(10.0)\r\nTraceback (most recent call last):\r\n File \"\u003cstdin\u003e\", line 1, in \u003cmodule\u003e\r\nValueError: Format code 'G' for object of type 'float' not implemented yet\r\n\u003e\u003e\u003e\u003e\u003e '{:e}'.format(10.0)\r\nTraceback (most recent call last):\r\n File \"\u003cstdin\u003e\", line 1, in \u003cmodule\u003e\r\nValueError: Format code 'e' for object of type 'float' not implemented yet\r\n\u003e\u003e\u003e\u003e\u003e '{:E}'.format(10.0)\r\nTraceback (most recent call last):\r\n File \"\u003cstdin\u003e\", line 1, in \u003cmodule\u003e\r\nValueError: Format code 'E' for object of type 'float' not implemented yet\r\n\u003e\u003e\u003e\u003e\u003e '{:n}'.format(10.0)\r\nTraceback (most recent call last):\r\n File \"\u003cstdin\u003e\", line 1, in \u003cmodule\u003e\r\nValueError: Format code 'n' for object of type 'float' not implemented yet\r\n\u003e\u003e\u003e\u003e\u003e '{:%}'.format(10.0)\r\n'10.0'\r\n```\r\n\r\n## Python Documentation\r\n\r\nSee the section after `The available presentation types for floating point and decimal values are` in the docs found [here](https://docs.python.org/3/library/string.html#format-specification-mini-language).\r\n","author":{"url":"https://github.com/doyshinda","@type":"Person","name":"doyshinda"},"datePublished":"2020-01-02T23:09:28.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":3},"url":"https://github.com/1656/RustPython/issues/1656"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:d3da3684-b6d5-1bc6-c892-513bccc2fc04 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 862E:52BFD:12443BD:1A52BD0:6A58E87F |
| html-safe-nonce | 04cdcdf1afcad1d512ea051375ec0b78859adf13f8af8e73b436da5ab020f7ba |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4NjJFOjUyQkZEOjEyNDQzQkQ6MUE1MkJEMDo2QTU4RTg3RiIsInZpc2l0b3JfaWQiOiIzMTY0MDg5MTIwMTE4NTk3NzU5IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 632dac900196b5ee7ecbdbb8cf6d1a7f50a52a2a002cacebf4d6b8a5284a1466 |
| hovercard-subject-tag | issue:544785952 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/RustPython/RustPython/1656/issue_layout |
| twitter:image | https://opengraph.githubassets.com/12946278aa0773b56b20af77257f2a1b11e1d72e2ac0fa1a6b59e26b7f0b069f/RustPython/RustPython/issues/1656 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/12946278aa0773b56b20af77257f2a1b11e1d72e2ac0fa1a6b59e26b7f0b069f/RustPython/RustPython/issues/1656 |
| og:image:alt | Feature Implement the g, G, e, E, n, and % format codes for floats. g G e E n % A few examples from CPython: >>> '{:g}'.format(10.0) '10' >>> '{:.1g}'.format(10.0) '1e+01' >>> '{:e}'.format(10.0) '... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | doyshinda |
| hostname | github.com |
| expected-hostname | github.com |
| None | 5f2a0c7865178af3d91dd9f13b0cdfc3c73a2529c873d2780bb4c01271a57ec6 |
| turbo-cache-control | no-preview |
| go-import | github.com/RustPython/RustPython git https://github.com/RustPython/RustPython.git |
| octolytics-dimension-user_id | 39710557 |
| octolytics-dimension-user_login | RustPython |
| octolytics-dimension-repository_id | 135201145 |
| octolytics-dimension-repository_nwo | RustPython/RustPython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 135201145 |
| octolytics-dimension-repository_network_root_nwo | RustPython/RustPython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 8aae7b8d6caacacf5c66eaeb2702d8dc88d85b4a |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width