Dear Mike,

Thanks a lot for that, this looks very promising. However, after
making the suggested change, the behaviour of latex() did not change.
Do I need to restart sage for the changes to take effect?
dummy._latex_?? reflects the changes made, but the 0s are still there
when I latex(dummy).

dummy = 0.6;dummy
0.600000000000000

dummy._latex_??
File: /Users/sschym/Programs/sage/devel/sage/sage/rings/real_mpfr.pyx
Source Code (starting at line 959):
    def _latex_(self):
        s = self.str()
        parts = s.split('e')
        if len(parts) > 1:
            # scientific notation
            if parts[1][0] == '+':
                parts[1] = parts[1][1:]
            s = "%s \\times 10^{%s}" % (str(parts[0]).rstrip('0'),
parts[1])
        else:
                s = s.rstrip('0')
        return s

latex(dummy)
0.600000000000000


Cheers
Stan



On Nov 17, 4:42 pm, "Mike Hansen" <[EMAIL PROTECTED]> wrote:
> If a is your real number, and then a._latex_?? will point you in the
> direction that you need to go.  It leads to the _latex_ function for
> which there really isn't anything deep going on.
>
> If all you care about is truncating zeros, then following changes will do:
>
> diff -r 07a824fa8f2b sage/rings/real_mpfr.pyx
> --- a/sage/rings/real_mpfr.pyx  Sun Nov 16 06:26:41 2008 -0800
> +++ b/sage/rings/real_mpfr.pyx  Mon Nov 17 07:41:40 2008 -0800
> @@ -963,7 +963,9 @@
>              # scientific notation
>              if parts[1][0] == '+':
>                  parts[1] = parts[1][1:]
> -            s = "%s \\times 10^{%s}" % (parts[0], parts[1])
> +            s = "%s \\times 10^{%s}" % (str(parts[0]).rstrip('0'), parts[1])
> +        else:
> +            s = s.rstrip('0')
>          return s
>
> --Mike
--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to