From: ChrisH Date: 2006-07-26T04:20:05+09:00 Subject: Re: Noob devision question ChrisH wrote: > jamiethehutt wrote: > ... > > totalbarsize = 180 > > timeelapsed = 10 > > totaltime = 30 > > > > percomplete = 0.0 > > barlength = 0.0 > > > > percomplete = timeelapsed / totaltime > > barlength = totalbarsize*percomplete > > > > puts barlength > > You need Floats all the way down. > The division of Fixnum values ( timeelapsed / totaltime) > produces a Fixnum value, which is 0 as 0.333 gets truncated > > put a .0 after all the non-Float values to force them to be Float Fogot to say, to get an Integer (or Fixnum id Ruby parlance) just call to_i on the Float value to covert by truncating the value. cheers