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

Bad sign in sign_mantissa_exponent() methods #14448

Closed
sagetrac-tmonteil mannequin opened this issue Apr 14, 2013 · 12 comments
Closed

Bad sign in sign_mantissa_exponent() methods #14448

sagetrac-tmonteil mannequin opened this issue Apr 14, 2013 · 12 comments

Comments

@sagetrac-tmonteil
Copy link
Mannequin

sagetrac-tmonteil mannequin commented Apr 14, 2013

The .sign_mantissa_exponent() methods of the RealNumber and RealDoubleElement classes give a negative mantissa when the number is negative, which does not corresponds to the behaviour described in the documentation :
http://www.sagemath.org/doc/reference/rings_numerical/sage/rings/real_mpfr.html
http://www.sagemath.org/doc/reference/rings_numerical/sage/rings/real_double.html

We propose here to fix it.

By the way, the variable name 'mantissa' sometimes (always?) appears in the source with the meaning of a signed mantissa. I would suggest to renamed it signed_mantissa or s_mantissa to ease code reading (though i do not feel able to detect which one is signed or not along the code). See for example the .exact_rational() method in real_mpfr.pyx.


Apply: attachment: trac_14448_sign_of_mantissa-tm.2.patch

CC: @jasongrout @zimmermann6

Component: basic arithmetic

Keywords: mpfr, RDF

Author: Thierry Monteil

Reviewer: Travis Scrimshaw

Merged: sage-5.10.beta0

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

@sagetrac-tmonteil sagetrac-tmonteil mannequin added this to the sage-5.10 milestone Apr 14, 2013
@sagetrac-tmonteil
Copy link
Mannequin Author

sagetrac-tmonteil mannequin commented Apr 14, 2013

Attachment: trac_14448_sign_of_mantissa-tm.patch.gz

Tested on sage 5.9.beta5

@sagetrac-tmonteil

This comment has been minimized.

@sagetrac-tmonteil
Copy link
Mannequin Author

sagetrac-tmonteil mannequin commented Apr 14, 2013

Changed keywords from mpfr, float to mpfr, RDF

@tscrim
Copy link
Collaborator

tscrim commented Apr 14, 2013

comment:2

I'm guessing this is ready for review?

Looks good, but one small thing, could you change line 2930 in real_mpfr.pyx to:

The mantissa is always a nonnegative number (see :trac:`14448`)::

or something to this extent, noting the problem was fixed in this ticket?

Thanks,

Travis

@jdemeyer
Copy link

comment:3

I think it's a bug that the mantissa of 1 and -1 are different.

@sagetrac-tmonteil
Copy link
Mannequin Author

sagetrac-tmonteil mannequin commented Apr 15, 2013

Patch updated so that it quotes this trac ticket

@sagetrac-tmonteil
Copy link
Mannequin Author

sagetrac-tmonteil mannequin commented Apr 15, 2013

comment:5

Attachment: trac_14448_sign_of_mantissa-tm.2.patch.gz

I added the reference to this trac ticket. I also put this ticket under review.

@tscrim
Copy link
Collaborator

tscrim commented Apr 15, 2013

comment:6

Looks good to me.

@tscrim
Copy link
Collaborator

tscrim commented Apr 15, 2013

Reviewer: Travis Scrimshaw

@tscrim
Copy link
Collaborator

tscrim commented Apr 15, 2013

Author: Thierry Monteil

@tscrim

This comment has been minimized.

@jdemeyer
Copy link

Merged: sage-5.10.beta0

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

3 participants