def enough_precision(value)
      scale = [1.0, 10.0, 100.0, 1000.0, 10000.0, 100000.0]
      enough = lambda { |v| (v >= 10.0   ? 0 :
                            (v >= 1.0    ? 1 :
                            (v >= 0.1    ? 2 :
                            (v >= 0.01   ? 3 :
                            (v >  0.001  ? 4 :
                            (v >  0.0    ? 5 : 0)))))) }
      digit_str = lambda { |p, v| sprintf("%.#{p}f", (v * scale[p]).round / scale[p])}
      digit_str.call(enough.call(value), value)
    end
def enough_precision(value)
      scale = [1.0, 10.0, 100.0, 1000.0, 10000.0, 100000.0]
      enough = lambda { |v| (v >= 10.0   ? 0 :
                            (v >= 1.0    ? 1 :
                            (v >= 0.1    ? 2 :
                            (v >= 0.01   ? 3 :
                            (v >  0.001  ? 4 :
                            (v >  0.0    ? 5 : 0)))))) }
      digit_str = lambda { |p, v| sprintf("%.#{p}f", (v * scale[p]).round / scale[p])}
      digit_str.call(enough.call(value), value)
    end
Determine enough precision for floating point value to give at least two significant
 digits and then convert the value to a decimal digit string of that precision

 === Parameters
 value(Float):: Value to be converted

 === Return
 (String):: Floating point digit string