Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

decimal form of a unit converted answer

I was wondering what a good way might be to get a decimal answer when using units. For example, say I try

#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

Now, suppose I'd rather see this represented as a decimal than a fraction (for homework, perhaps?). 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.

Can anyone think of a good solution to this?

click to hide/show revision 2
formatting

decimal form of a unit converted answer

I was wondering what a good way might be to get a decimal answer when using units. For example, say I try

#define units

units ft = units.length.foot

units.length.foot m = units.length.meter

units.length.meter #add some lengths and output in ft

ft (3*ft + 4*m).convert(units.length.ft)4*m).convert(units.length.ft)

I get back

6143/381*foot6143/381*foot

Now, suppose I'd rather see this represented as a decimal than a fraction (for homework, perhaps?). If I try

(3*ft + 4*m).convert(units.length.foot).n()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.

Can anyone think of a good solution to this?