On Thu, Jun 17, 2010 at 3:10 AM, smichr <[email protected]> wrote:
> Matteo asked a question about units (but hijacked another discussion
> to do so) :-)
>
> -------------
> Hi All,
> I'm trying to use sympy for units conversion..
> I use this code to convert from ft to mm..
> cad_leng=units.Unit('cad_leng','mm')
> converter={units.m: cad_leng*Rational(1000)}
> cad_ft=units.ft
> cad_mm=cad_ft.subs(converter)
> mm_value=float(str(cad_mm.evalf()).split('*')[0])
> print mm_value
> 304.8
>
> Is this right ?
> Or there are any other method to get it ?
> -------------
>
> Matteo, I would do it like this:
>
>>>> from sympy.physics import units as u
>>>> u.feet/u.mm
> 1524/5
>>>> _.n()
> 304.800000000000
>
ok, let's keep hijacking...
just out of curiosity - how did you get all those trailing zeros ?

thanks and sorry for the off-topic question,
Sebastian

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sympy?hl=en.

Reply via email to