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

reconsider how floating point values are printed #960

Closed
williamstein opened this issue Oct 21, 2007 · 3 comments
Closed

reconsider how floating point values are printed #960

williamstein opened this issue Oct 21, 2007 · 3 comments

Comments

@williamstein
Copy link
Contributor

some f-p values are printed like integers, which may confuse the user
 (especially if one copies them with the mouse):
 sage: 2.0^46
 70368744177664.0
 sage: 2.0^47
 140737488355328
 I would expect '140737488355328.' or '1.40737488355328e14' in the 2nd case.
 By the way, typing 140737488355328.0 outputs itself, which is inconsistent,
 since 140737488355328.0-2.0^47 gives 0.0000000000000000.

 Compare also:
 sage: 2.0^99
 633825300114115000000000000000
 sage: 2.0^100
 1.26765060022823e30

My 2 cents,
Paul Z.

Component: basic arithmetic

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

@sagetrac-mabshoff

This comment has been minimized.

@sagetrac-mabshoff sagetrac-mabshoff mannequin added this to the sage-2.8.9 milestone Oct 21, 2007
@sagetrac-cwitty
Copy link
Mannequin

sagetrac-cwitty mannequin commented Oct 21, 2007

comment:3

The inconsistency mentioned is because of the automagic behavior of decimal literals, where longer literals get more bits:

sage: (2.0^47).prec()
53
sage: (140737488355328.0).prec()
56

Maybe this magic behavior should be removed, or somehow modified to be less confusing? (Although I have no idea how to make it less confusing.)

See also #962, for problems with the current implementation of the precision extension.

@mwhansen
Copy link
Contributor

comment:5

Attachment: mpfr.patch.gz

I've attached a patch that makes sure that all real numbers include a "." so that they don't get confused with integers.

Here is the behavior after the patch

sage:  2.0^47
140737488355328.
sage:  2.0^46
70368744177664.0
sage:  2.0^99
633825300114115000000000000000.
sage:  2.0^100
1.26765060022823e30
sage: 140737488355328.
140737488355328.
sage: a = 2.0^47
sage: a
140737488355328.
sage: a.prec()
53
sage: b = 140737488355328.
sage: b.prec()
53

@sagetrac-mabshoff sagetrac-mabshoff mannequin modified the milestones: sage-2.8.9, sage-2.8.10 Oct 25, 2007
@sagetrac-cwitty sagetrac-cwitty mannequin assigned mwhansen and unassigned sagetrac-cwitty Oct 25, 2007
@sagetrac-cwitty sagetrac-cwitty mannequin closed this as completed Oct 27, 2007
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