# convert output

Hello, if a function gives an output like this

2.00000000000000 - 2.77555756156289e-17*I

how could one convert it to be simply

2

Bests

convert output

Hello, if a function gives an output like this

2.00000000000000 - 2.77555756156289e-17*I

how could one convert it to be simply

2

Bests

1

The `round`

function will give you the nearest number with a given number of digits. Note that it only works for real numbers, so you should round the real and imaginary parts separately.

If you just want to display fewer digits, but have sage remember more precision, then you can use python string formatting. See this question.

0

Maybe something like that ?

```
sage: QQ(real_part(2.00000000000000 - 2.77555756156289e-17*I))
2
```

Asked: **
2014-07-31 14:30:30 -0500
**

Seen: **74 times**

Last updated: **Aug 04 '14**

How to print a text file containing multiple tuples from a function

Huge output saved in nice format

Converting sin(x)^n to sin^n(x)

when typeset is checked on the notebook app, output is not showing [closed]

how to get output in a mixed fraction?

Output of a sequence in Display and as a txt-File

Why the value returned by read_data,open... are unavailable in Jupyter notebook

Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.

If you can give us the exact command which does this, it would be helpful. Sometimes this is a bug, and similar ones have been tracked (and fixed). Thanks!