Class | Lisp::Format::Directives::GeneralFP |
In: |
lib/facet/lisp-format.rb
|
Parent: | Directive |
Represents the ~G (General floating-point) directive. This outputs its argument using either a format like ~F or ~E depending upon given parameters and the magnitude of the argument.
Outputs the argument using exponential floating-point format. The algorithm to decide what format to use looks something like
let 10^n-1 <= arg < 10^n, or n = 0 if arg = 0, ee = e + 2, or ee = 4 if e undefined, ww = w - ee, or ww = nil if w undefined, dd = d - n, or dd = max(q, min(n, 7)) where q = number of characters necessary to print arg without loss of information in 0 <= dd <= d, and print using ~ww,dd,,overflowchar,padcharF~ee@T or print using ~w,d,e,k,overflowchar,padchar,exponentcharG
Use of the @ modifier in the directives above depends on if it was passed to ~G in the first place.
The full form is
~w,d,e,k,overflowchar,padchar,exponentchar@G
with the following interpretations
An ArgumentError is raised if the argument is not a number or a string that can be converted to a number.