code: function dec2frac(d) {
  
    var df = 1;
    var top = 1;
    var bot = 1;
  
    while (df != d) {
      if (df < d) {
        top += 1;
      }
      else {
        bot += 1;
        top = parseInt(d * bot);
      }
      df = top / bot;
    }
    return top + '/' + bot;
  }
docs: source: http://stackoverflow.com/questions/95727/how-to-convert-floats-to-human-readable-fractions