It turns out the solution is quite simple. (I feel stupid for not figuring 
this one out on my own) In order to get an answer in decimal form, all i 
have to do is...

   #define units
   ft =  units.length.foot
   m = units.length.meter
   
   #add some lengths and convert to ft
   (3.0*ft + 4.0*m).convert(units.length.foot)

This gives

   16.1233595800525*foot

Haha. Silly me.

Also, say pi was a part of my length. I'd just do something like

   (4.0*(pi.n())*ft + 5.0*m).convert(units.length.foot)


Justin

On Sunday, May 20, 2012 12:15:18 AM UTC-7, Justin wrote:
>
> I was wondering what a good way might be to get a decimal answer when 
> using units. For example, say I try
>
> For example, say I do
>
>    #define units
>    ft =  units.length.foot
>    m = units.length.meter
>
>    #add some lengths and output in ft
>    (3*ft + 4*m).convert(units.length.ft)
>
> I get back
>
>    6143/381*foot
>
> Awesome! However, suppose I'd rather see this represented as a decimal 
> than a fraction. If I try
>
>    (3*ft + 4*m).convert(units.length.foot).n()
>
> I get an error. This is occuring on Sage 4.8 for sure, and I'm pretty sure 
> in Sage 5.0 as well.
>
> Does anyone know why this is doing this or how I might better ask Sage to 
> give me a decimal answer of converted units?
>
>
> Thank you in advance,
>
>
> Justin
>
>

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org

Reply via email to