Ask Your Question

Arrgh_Jay's profile - activity

2019-02-18 23:11:14 +0200 received badge  Famous Question (source)
2019-02-18 23:11:14 +0200 received badge  Notable Question (source)
2015-03-10 00:37:46 +0200 received badge  Popular Question (source)
2012-05-21 01:21:13 +0200 received badge  Scholar (source)
2012-05-21 01:21:13 +0200 marked best answer decimal form of a unit converted answer

It is better to write the units to convert in decimal form

#define units
ft =  units.length.foot
m = units.length.meter
#add some lengths and output in ft
(3.0*ft+4.0*m).convert(units.length.foot)
2012-05-21 01:20:58 +0200 commented answer decimal form of a unit converted answer

wow, do i feel dumb. i can't believe it didn't occur to me to try that. thank you.

2012-05-21 01:19:44 +0200 received badge  Supporter (source)
2012-05-20 17:52:06 +0200 asked a question 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?