to_s(p1 = v1) public

Converts the value to a string.

The default format looks like 0.xxxxEnn.

The optional parameter s consists of either an integer; or an optional ‘+’ or ‘ ’, followed by an optional number, followed by an optional ‘E’ or ‘F’.

If there is a ‘+’ at the start of s, positive values are returned with a leading ‘+’.

A space at the start of s returns positive values with a leading space.

If s contains a number, a space is inserted after each group of that many fractional digits.

If s ends with an ‘E’, engineering notation (0.xxxxEnn) is used.

If s ends with an ‘F’, conventional floating point notation is used.


BigDecimal.new(‘-123.45678901234567890’).to_s(‘5F’) -> ‘-123.45678 90123 45678 9’

BigDecimal.new(‘123.45678901234567890’).to_s(‘+8F’) -> ‘+123.45678901 23456789’

BigDecimal.new(‘123.45678901234567890’).to_s(‘ F’) -> ‘ 123.4567890123456789’

Show source
Register or log in to add new notes.