summaryrefslogtreecommitdiff
path: root/vendor/bundle/ruby/3.4.0/gems/bigdecimal-4.1.2/sig/big_decimal_util.rbs
blob: 4c5bfce212e9d7d2310f5547d5fdfe3dfad80794 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
%a{annotate:rdoc:skip}
class Integer
  # <!--
  #   rdoc-file=lib/bigdecimal/util.rb
  #   - int.to_d  -> bigdecimal
  # -->
  # Returns the value of `int` as a BigDecimal.
  #
  #     require 'bigdecimal'
  #     require 'bigdecimal/util'
  #
  #     42.to_d   # => 0.42e2
  #
  # See also Kernel.BigDecimal.
  #
  def to_d: () -> BigDecimal
end

%a{annotate:rdoc:skip}
class Float
  # <!--
  #   rdoc-file=lib/bigdecimal/util.rb
  #   - float.to_d             -> bigdecimal
  #   - float.to_d(precision)  -> bigdecimal
  # -->
  # Returns the value of `float` as a BigDecimal. The `precision` parameter is
  # used to determine the number of significant digits for the result. When
  # `precision` is set to `0`, the number of digits to represent the float being
  # converted is determined automatically. The default `precision` is `0`.
  #
  #     require 'bigdecimal'
  #     require 'bigdecimal/util'
  #
  #     0.5.to_d         # => 0.5e0
  #     1.234.to_d       # => 0.1234e1
  #     1.234.to_d(2)    # => 0.12e1
  #
  # See also Kernel.BigDecimal.
  #
  def to_d: (?Integer precision) -> BigDecimal
end

%a{annotate:rdoc:skip}
class String
  # <!--
  #   rdoc-file=lib/bigdecimal/util.rb
  #   - str.to_d  -> bigdecimal
  # -->
  # Returns the result of interpreting leading characters in `str` as a
  # BigDecimal.
  #
  #     require 'bigdecimal'
  #     require 'bigdecimal/util'
  #
  #     "0.5".to_d             # => 0.5e0
  #     "123.45e1".to_d        # => 0.12345e4
  #     "45.67 degrees".to_d   # => 0.4567e2
  #
  # See also Kernel.BigDecimal.
  #
  def to_d: () -> BigDecimal
end

%a{annotate:rdoc:skip}
class BigDecimal
  # <!--
  #   rdoc-file=lib/bigdecimal/util.rb
  #   - a.to_digits -> string
  # -->
  # Converts a BigDecimal to a String of the form "nnnnnn.mmm". This method is
  # deprecated; use BigDecimal#to_s("F") instead.
  #
  #     require 'bigdecimal/util'
  #
  #     d = BigDecimal("3.14")
  #     d.to_digits                  # => "3.14"
  #
  def to_digits: () -> String

  # <!--
  #   rdoc-file=lib/bigdecimal/util.rb
  #   - a.to_d -> bigdecimal
  # -->
  # Returns self.
  #
  #     require 'bigdecimal/util'
  #
  #     d = BigDecimal("3.14")
  #     d.to_d                       # => 0.314e1
  #
  def to_d: () -> BigDecimal
end

%a{annotate:rdoc:skip}
class Rational
  # <!--
  #   rdoc-file=lib/bigdecimal/util.rb
  #   - rat.to_d(precision)  -> bigdecimal
  # -->
  # Returns the value as a BigDecimal.
  #
  # The `precision` parameter is used to determine the number of significant
  # digits for the result. When `precision` is set to `0`, the number of digits to
  # represent the float being converted is determined automatically. The default
  # `precision` is `0`.
  #
  #     require 'bigdecimal'
  #     require 'bigdecimal/util'
  #
  #     Rational(22, 7).to_d(3)   # => 0.314e1
  #
  # See also Kernel.BigDecimal.
  #
  def to_d: (Integer precision) -> BigDecimal
end

%a{annotate:rdoc:skip}
class Complex
  # <!--
  #   rdoc-file=lib/bigdecimal/util.rb
  #   - cmp.to_d             -> bigdecimal
  #   - cmp.to_d(precision)  -> bigdecimal
  # -->
  # Returns the value as a BigDecimal. If the imaginary part is not `0`, an error
  # is raised
  #
  # The `precision` parameter is used to determine the number of significant
  # digits for the result. When `precision` is set to `0`, the number of digits to
  # represent the float being converted is determined automatically. The default
  # `precision` is `0`.
  #
  #     require 'bigdecimal'
  #     require 'bigdecimal/util'
  #
  #     Complex(0.1234567, 0).to_d(4)   # => 0.1235e0
  #     Complex(Rational(22, 7), 0).to_d(3)   # => 0.314e1
  #     Complex(1, 1).to_d   # raises ArgumentError
  #
  # See also Kernel.BigDecimal.
  #
  def to_d: (*untyped args) -> BigDecimal
end

%a{annotate:rdoc:skip}
class NilClass
  # <!--
  #   rdoc-file=lib/bigdecimal/util.rb
  #   - nil.to_d -> bigdecimal
  # -->
  # Returns nil represented as a BigDecimal.
  #
  #     require 'bigdecimal'
  #     require 'bigdecimal/util'
  #
  #     nil.to_d   # => 0.0
  #
  def to_d: () -> BigDecimal
end