Method: Sunspot::Util.format_float
- Defined in:
- lib/sunspot/util.rb
.format_float(f, digits) ⇒ Object
When generating boosts, Solr requires that the values be in standard (not scientific) notation. We would like to ensure a minimum number of significant digits (i.e., digits that are not prefix zeros) for small float values.
133 134 135 136 137 138 139 |
# File 'lib/sunspot/util.rb', line 133 def format_float(f, digits) if f < 1 sprintf('%.*f', digits - Math.log10(f), f) else f.to_s end end |