# Revision history [back]

I worked on a ticket to help with this a while ago: http://trac.sagemath.org/sage_trac/ticket/7682

You can see a comment from Carl Witty that gives a good approach: http://trac.sagemath.org/sage_trac/ticket/7682#comment:32 (I really like his option 1). Basically, it allows for setting options for printing any numbers from a RealField.

For an individual number, you're looking for the skip_zeroes argument to str:

 sage: a 1.20000000000000 sage: a.str(skip_zeroes=True) '1.2' 

I worked on a ticket to help with this a while ago: http://trac.sagemath.org/sage_trac/ticket/7682

You can see a comment from Carl Witty that gives a good approach: http://trac.sagemath.org/sage_trac/ticket/7682#comment:32 (I really like his option 1). Basically, it allows for setting options for printing any numbers from a RealField.

For an individual number, you're looking for the skip_zeroes argument to str:

 sage: a
1.20000000000000
sage: a.str(skip_zeroes=True)
'1.2'


I worked on a ticket to help with this a while ago: http://trac.sagemath.org/sage_trac/ticket/7682

You can see a comment from Carl Witty that gives a good approach: http://trac.sagemath.org/sage_trac/ticket/7682#comment:32 (I really like his option 1). Basically, it allows for setting options for printing any numbers from a RealField.

For an individual number, you're looking for the skip_zeroes argument to str:

sage: a=1.2
sage: a
1.20000000000000
sage: a.str(skip_zeroes=True)
'1.2'


I worked on a ticket to help with this a while ago: http://trac.sagemath.org/sage_trac/ticket/7682

You can see a comment comment from Carl Witty that gives a good approach: http://trac.sagemath.org/sage_trac/ticket/7682#comment:32 (I really like his option 1). Basically, it allows for setting options for printing any numbers from a RealField.

For an individual number, you're looking for the skip_zeroes argument to str:

sage: a=1.2
sage: a
1.20000000000000
sage: a.str(skip_zeroes=True)
'1.2'


I worked on a ticket to help with this a while ago: http://trac.sagemath.org/sage_trac/ticket/7682

You can see a comment from Carl Witty that gives a good approach: (I really like his option 1). Basically, it allows for setting options for printing any numbers from a RealField.

For an individual number, you're looking for the skip_zeroes argument to str:

sage: a=1.2
sage: a
1.20000000000000
sage: a.str(skip_zeroes=True)
'1.2'


Alternatively, this is the default behavior for python floats (as opposed to Sage floating point numbers), so if you either turn off the preparser or use python floats, you'll get what you want:

sage: float(1.2)*x
1.2*x
sage: preparser(False)
sage: 1.2*x
1.2*x