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

function for floating point representation of a number #7830

Closed
jasongrout opened this issue Jan 3, 2010 · 19 comments
Closed

function for floating point representation of a number #7830

jasongrout opened this issue Jan 3, 2010 · 19 comments

Comments

@jasongrout
Copy link
Member

Here's a function that answers the question posed in http://groups.google.com/group/sage-devel/browse_thread/thread/c8c75b483f2c47f6 -- give the sign, mantissa, and exponent of a floating point number.

I also cleaned up a few minor other things.

Component: basic arithmetic

Author: Jason Grout

Reviewer: Robert Bradshaw, John Cremona

Merged: sage-4.3.2.alpha0

Issue created by migration from https://trac.sagemath.org/ticket/7830

@jasongrout
Copy link
Member Author

@robertwb
Copy link
Contributor

robertwb commented Jan 7, 2010

comment:2

Looks good. I don't like the name representation() either--maybe parts()?

@jasongrout
Copy link
Member Author

comment:3

parts() seems too vague. Maybe ieee_754_parts(), except that we support arbitrary precision, not just the set precisions they mention. Maybe floating_point_representation(), or sign_mantissa_exponent().

I'm willing to concede on the naming to make sure this gets in before I start my numerical analysis class in two weeks :).

@robertwb
Copy link
Contributor

robertwb commented Jan 7, 2010

comment:4

Lets go with sign_mantissa_exponent(). Verbose but clear, and one doesn't even have to look at the docstring every time to remember what order the tuple comes in :)

@jasongrout
Copy link
Member Author

apply on top of previous patch

@jasongrout
Copy link
Member Author

comment:5

Attachment: trac-7830-change-name.patch.gz

Okay, I added a patch which changes the name. This is hopefully ready for a positive review now :).

@JohnCremona
Copy link
Member

comment:6

I see that you have only added this method to mpfr. Should we not preserve as much consistency as possible between the different real types by also adding it to real_double?

@jasongrout
Copy link
Member Author

comment:7

Very good point. I'll look at this. I might just end up creating an RR number and calling this method behind the scenes

@jasongrout
Copy link
Member Author

Attachment: trac-7830-sign_m_e.patch.gz

apply on top of previous patches

@jasongrout
Copy link
Member Author

comment:8

I've added a similar function to RDF now.

@robertwb
Copy link
Contributor

comment:9

http://en.wikipedia.org/wiki/IEEE_754-1985

The exponent for 0 should be 0. This also avoids the issue of platform dependance for that value, and RDF(0)'s exponent being unrealistically small.

Also, sage/rings/real_mpfr.pyx, line 1890 should be EXAMPLES::

@jasongrout
Copy link
Member Author

Attachment: trac-7830-fixes.patch.gz

apply on top of previous patches

@jasongrout
Copy link
Member Author

comment:10

The last patch fixes a few other documentation errors and an error in multiplicative_order too. For free.

@robertwb
Copy link
Contributor

all four of the above folded into one

@robertwb
Copy link
Contributor

comment:11

Attachment: 7830-real-rep-all.patch.gz

Looks good.

@sagetrac-mvngu
Copy link
Mannequin

sagetrac-mvngu mannequin commented Jan 22, 2010

Merged: sage-4.3.2.alpha0

@sagetrac-mvngu
Copy link
Mannequin

sagetrac-mvngu mannequin commented Jan 22, 2010

Author: Jason Grout

@sagetrac-mvngu
Copy link
Mannequin

sagetrac-mvngu mannequin commented Jan 22, 2010

Reviewer: Robert Bradshaw, John Cremona

@sagetrac-mvngu sagetrac-mvngu mannequin closed this as completed Jan 22, 2010
@jasongrout
Copy link
Member Author

comment:13

The mantissa and exponent for MPFR is not the same as the mantissa and exponent for IEEE 754. So I'm a little doubtful about the choice to follow IEEE 754 conventions for the exponent value of 0. (but I'm not doubtful enough to change it). I just thought I'd point out that the values from MPFR are different than the conventions from IEEE 754 for the same floating point number.

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

4 participants