to_s
- 1_8_6_287
- 1_8_7_72
- 1_8_7_330
- 1_9_1_378 (0)
- 1_9_2_180 (-1)
- 1_9_3_125 (0)
- 1_9_3_392 (0)
- 2_1_10 (38)
- 2_2_9 (0)
- 2_4_6 (-20)
- 2_5_5 (-10)
- 2_6_3 (0)
- What's this?
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.
Examples:
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'