From: Alex LeDonne Date: 2007-07-02T23:30:26+09:00 Subject: Re: simple math operations on arrays On 7/1/07, baptiste Augui� wrote: > yep, i do want (-2/3). Oh, i see, is 2/3 == 1 for Ruby?? OMG this is > mad ! > > thanks, it works now! > > > radius=0.045 > aspectRatio=[] > longAxis=[] > shortAxis=[] > > 0.5.step(1, 0.1) { |x| aspectRatio << x.to_s } > > longAxis=aspectRatio.collect{ |x| radius*((x.to_f)**(-2/3.to_f)) } > aspectRatio.each_index { |x| shortAxis << longAxis[x].to_f*aspectRatio > [x].to_f} > puts longAxis > puts shortAxis > > > > any easier / more elegant way to do all this ? > > > thanks, > > baptiste Instead of (-2/3.to_f) , you could use (-2.0/3). By using a float literal rather than an integer literal, you will get float division rather than integer division. -A