Opened 12 years ago
Closed 8 years ago
#7829 closed defect (fixed)
implement hex for real numbers
Reported by: | robertwb | Owned by: | AlexGhitza |
---|---|---|---|
Priority: | minor | Milestone: | sage-6.3 |
Component: | basic arithmetic | Keywords: | |
Cc: | Merged in: | ||
Authors: | Marc Mezzarobba | Reviewers: | Robert Bradshaw |
Report Upstream: | N/A | Work issues: | |
Branch: | 847a899 (Commits, GitHub, GitLab) | Commit: | 847a899993b6a67f4af785cd0bbccf77ab1544da |
Dependencies: | Stopgaps: |
Description
sage: float(e).hex() '0x1.5bf0a8b145769p+1' sage: RR(e).hex() ------------------------------------------------------------ Traceback (most recent call last): File "<ipython console>", line 1, in <module> AttributeError: 'sage.rings.real_mpfr.RealNumber' object has no attribute 'hex'
There should probably be a hex method as well, so hex(2.3) works.
Change History (8)
comment:1 Changed 8 years ago by
- Branch set to u/mmezzarobba/7829-hex_RR
- Commit set to 9eb5896887f1c258de45802fe4b68febbd615dc2
- Component changed from algebra to basic arithmetic
- Milestone changed from sage-wishlist to sage-6.3
- Status changed from new to needs_review
comment:2 Changed 8 years ago by
- Commit changed from 9eb5896887f1c258de45802fe4b68febbd615dc2 to efff26a727fddf350b6a8a2a0e5614411306b3c7
Branch pushed to git repo; I updated commit sha1. New commits:
efff26a | also provide RR(...).__hex__()
|
comment:3 follow-up: ↓ 6 Changed 8 years ago by
Does the C string need to be freed in the error case as well? In that case you could use a finally clause (and just "return s")
Could you add a test showing that hex(RR(x)) works too?
comment:4 Changed 8 years ago by
Just a short comment: I think the new syntax for exceptions should be used, i.e. raise RuntimeError("...")
.
comment:5 Changed 8 years ago by
- Commit changed from efff26a727fddf350b6a8a2a0e5614411306b3c7 to 847a899993b6a67f4af785cd0bbccf77ab1544da
Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:
847a899 | implement RR(...).__hex__() and RR(...).hex()
|
comment:6 in reply to: ↑ 3 Changed 8 years ago by
Replying to robertwb:
Does the C string need to be freed in the error case as well?
As far as I understand, no, it doesn't.
Could you add a test showing that hex(RR(x)) works too?
Done.
Replying to jkeitel:
I think the new syntax for exceptions should be used, i.e. raise RuntimeError?("...").
Fixed, thanks!
comment:7 Changed 8 years ago by
- Reviewers set to Robert Bradshaw
- Status changed from needs_review to positive_review
comment:8 Changed 8 years ago by
- Branch changed from u/mmezzarobba/7829-hex_RR to 847a899993b6a67f4af785cd0bbccf77ab1544da
- Resolution set to fixed
- Status changed from positive_review to closed
New commits:
implement RR(...).hex()