rbs 4.0.0.dev.4 → 4.0.0.dev.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (223) hide show
  1. checksums.yaml +4 -4
  2. data/.github/dependabot.yml +14 -14
  3. data/.github/workflows/bundle-update.yml +60 -0
  4. data/.github/workflows/c-check.yml +11 -8
  5. data/.github/workflows/comments.yml +3 -3
  6. data/.github/workflows/dependabot.yml +1 -1
  7. data/.github/workflows/ruby.yml +17 -34
  8. data/.github/workflows/typecheck.yml +2 -2
  9. data/.github/workflows/valgrind.yml +42 -0
  10. data/.github/workflows/windows.yml +2 -2
  11. data/.rubocop.yml +1 -1
  12. data/README.md +1 -1
  13. data/Rakefile +32 -5
  14. data/config.yml +46 -0
  15. data/core/array.rbs +96 -46
  16. data/core/binding.rbs +0 -2
  17. data/core/builtin.rbs +2 -2
  18. data/core/comparable.rbs +13 -6
  19. data/core/complex.rbs +55 -41
  20. data/core/dir.rbs +4 -4
  21. data/core/encoding.rbs +7 -10
  22. data/core/enumerable.rbs +90 -3
  23. data/core/enumerator/arithmetic_sequence.rbs +70 -0
  24. data/core/enumerator.rbs +63 -1
  25. data/core/errno.rbs +8 -0
  26. data/core/errors.rbs +28 -1
  27. data/core/exception.rbs +2 -2
  28. data/core/fiber.rbs +40 -20
  29. data/core/file.rbs +108 -78
  30. data/core/file_test.rbs +1 -1
  31. data/core/float.rbs +225 -69
  32. data/core/gc.rbs +417 -281
  33. data/core/hash.rbs +1023 -727
  34. data/core/integer.rbs +104 -110
  35. data/core/io/buffer.rbs +21 -10
  36. data/core/io/wait.rbs +11 -33
  37. data/core/io.rbs +82 -19
  38. data/core/kernel.rbs +70 -59
  39. data/core/marshal.rbs +1 -1
  40. data/core/match_data.rbs +1 -1
  41. data/core/math.rbs +42 -3
  42. data/core/method.rbs +63 -27
  43. data/core/module.rbs +103 -26
  44. data/core/nil_class.rbs +3 -3
  45. data/core/numeric.rbs +43 -35
  46. data/core/object.rbs +3 -3
  47. data/core/object_space.rbs +21 -15
  48. data/core/pathname.rbs +1272 -0
  49. data/core/proc.rbs +30 -25
  50. data/core/process.rbs +4 -2
  51. data/core/ractor.rbs +361 -509
  52. data/core/random.rbs +17 -0
  53. data/core/range.rbs +113 -16
  54. data/core/rational.rbs +56 -85
  55. data/core/rbs/unnamed/argf.rbs +2 -2
  56. data/core/rbs/unnamed/env_class.rbs +1 -1
  57. data/core/rbs/unnamed/random.rbs +4 -113
  58. data/core/regexp.rbs +25 -20
  59. data/core/ruby.rbs +53 -0
  60. data/core/ruby_vm.rbs +6 -4
  61. data/core/rubygems/errors.rbs +3 -70
  62. data/core/rubygems/rubygems.rbs +11 -79
  63. data/core/rubygems/version.rbs +2 -3
  64. data/core/set.rbs +488 -359
  65. data/core/signal.rbs +24 -14
  66. data/core/string.rbs +3171 -1241
  67. data/core/struct.rbs +1 -1
  68. data/core/symbol.rbs +17 -11
  69. data/core/thread.rbs +95 -33
  70. data/core/time.rbs +35 -9
  71. data/core/trace_point.rbs +7 -4
  72. data/core/unbound_method.rbs +14 -6
  73. data/docs/aliases.md +79 -0
  74. data/docs/collection.md +2 -2
  75. data/docs/encoding.md +56 -0
  76. data/docs/gem.md +0 -1
  77. data/docs/inline.md +470 -0
  78. data/docs/sigs.md +3 -3
  79. data/docs/syntax.md +33 -4
  80. data/docs/type_fingerprint.md +21 -0
  81. data/exe/rbs +1 -1
  82. data/ext/rbs_extension/ast_translation.c +77 -3
  83. data/ext/rbs_extension/ast_translation.h +3 -0
  84. data/ext/rbs_extension/class_constants.c +8 -2
  85. data/ext/rbs_extension/class_constants.h +4 -0
  86. data/ext/rbs_extension/extconf.rb +5 -1
  87. data/ext/rbs_extension/legacy_location.c +5 -5
  88. data/ext/rbs_extension/main.c +37 -20
  89. data/include/rbs/ast.h +85 -38
  90. data/include/rbs/defines.h +27 -0
  91. data/include/rbs/lexer.h +30 -11
  92. data/include/rbs/parser.h +6 -6
  93. data/include/rbs/string.h +0 -2
  94. data/include/rbs/util/rbs_allocator.h +34 -13
  95. data/include/rbs/util/rbs_assert.h +12 -1
  96. data/include/rbs/util/rbs_encoding.h +2 -0
  97. data/include/rbs/util/rbs_unescape.h +2 -1
  98. data/lib/rbs/ast/annotation.rb +1 -1
  99. data/lib/rbs/ast/comment.rb +1 -1
  100. data/lib/rbs/ast/declarations.rb +10 -10
  101. data/lib/rbs/ast/members.rb +14 -14
  102. data/lib/rbs/ast/ruby/annotations.rb +137 -0
  103. data/lib/rbs/ast/ruby/comment_block.rb +24 -0
  104. data/lib/rbs/ast/ruby/declarations.rb +198 -3
  105. data/lib/rbs/ast/ruby/helpers/constant_helper.rb +4 -0
  106. data/lib/rbs/ast/ruby/members.rb +159 -1
  107. data/lib/rbs/ast/type_param.rb +24 -4
  108. data/lib/rbs/buffer.rb +20 -15
  109. data/lib/rbs/cli/diff.rb +16 -15
  110. data/lib/rbs/cli/validate.rb +38 -51
  111. data/lib/rbs/cli.rb +52 -19
  112. data/lib/rbs/collection/config/lockfile_generator.rb +8 -0
  113. data/lib/rbs/collection/sources/git.rb +1 -0
  114. data/lib/rbs/definition.rb +1 -1
  115. data/lib/rbs/definition_builder/ancestor_builder.rb +62 -9
  116. data/lib/rbs/definition_builder/method_builder.rb +20 -0
  117. data/lib/rbs/definition_builder.rb +91 -2
  118. data/lib/rbs/diff.rb +7 -1
  119. data/lib/rbs/environment.rb +227 -74
  120. data/lib/rbs/environment_loader.rb +0 -6
  121. data/lib/rbs/errors.rb +27 -7
  122. data/lib/rbs/inline_parser.rb +341 -5
  123. data/lib/rbs/location_aux.rb +1 -1
  124. data/lib/rbs/locator.rb +5 -1
  125. data/lib/rbs/method_type.rb +5 -3
  126. data/lib/rbs/parser_aux.rb +2 -2
  127. data/lib/rbs/prototype/rb.rb +2 -2
  128. data/lib/rbs/prototype/rbi.rb +2 -0
  129. data/lib/rbs/prototype/runtime.rb +8 -0
  130. data/lib/rbs/resolver/constant_resolver.rb +2 -2
  131. data/lib/rbs/resolver/type_name_resolver.rb +116 -38
  132. data/lib/rbs/subtractor.rb +3 -1
  133. data/lib/rbs/test/type_check.rb +16 -2
  134. data/lib/rbs/type_name.rb +1 -1
  135. data/lib/rbs/types.rb +27 -27
  136. data/lib/rbs/validator.rb +2 -2
  137. data/lib/rbs/version.rb +1 -1
  138. data/lib/rbs.rb +1 -1
  139. data/lib/rdoc/discover.rb +1 -1
  140. data/lib/rdoc_plugin/parser.rb +1 -1
  141. data/rbs.gemspec +3 -2
  142. data/schema/typeParam.json +17 -1
  143. data/sig/ast/ruby/annotations.rbs +124 -0
  144. data/sig/ast/ruby/comment_block.rbs +8 -0
  145. data/sig/ast/ruby/declarations.rbs +102 -4
  146. data/sig/ast/ruby/members.rbs +87 -1
  147. data/sig/cli/diff.rbs +5 -11
  148. data/sig/cli/validate.rbs +13 -4
  149. data/sig/cli.rbs +18 -18
  150. data/sig/definition.rbs +6 -1
  151. data/sig/environment.rbs +70 -12
  152. data/sig/errors.rbs +13 -6
  153. data/sig/inline_parser.rbs +39 -2
  154. data/sig/locator.rbs +0 -2
  155. data/sig/manifest.yaml +0 -1
  156. data/sig/method_builder.rbs +3 -1
  157. data/sig/method_types.rbs +1 -1
  158. data/sig/parser.rbs +16 -2
  159. data/sig/resolver/type_name_resolver.rbs +35 -7
  160. data/sig/source.rbs +3 -3
  161. data/sig/type_param.rbs +13 -8
  162. data/sig/types.rbs +4 -4
  163. data/src/ast.c +80 -1
  164. data/src/lexer.c +1392 -1313
  165. data/src/lexer.re +3 -0
  166. data/src/lexstate.c +58 -37
  167. data/src/location.c +4 -4
  168. data/src/parser.c +412 -145
  169. data/src/string.c +0 -48
  170. data/src/util/rbs_allocator.c +89 -71
  171. data/src/util/rbs_assert.c +1 -1
  172. data/src/util/rbs_buffer.c +2 -2
  173. data/src/util/rbs_constant_pool.c +10 -10
  174. data/src/util/rbs_encoding.c +4 -8
  175. data/src/util/rbs_unescape.c +56 -20
  176. data/stdlib/bigdecimal/0/big_decimal.rbs +100 -82
  177. data/stdlib/bigdecimal-math/0/big_math.rbs +169 -8
  178. data/stdlib/cgi/0/core.rbs +9 -393
  179. data/stdlib/cgi/0/manifest.yaml +1 -0
  180. data/stdlib/cgi-escape/0/escape.rbs +171 -0
  181. data/stdlib/coverage/0/coverage.rbs +3 -1
  182. data/stdlib/date/0/date.rbs +67 -59
  183. data/stdlib/date/0/date_time.rbs +1 -1
  184. data/stdlib/delegate/0/delegator.rbs +10 -7
  185. data/stdlib/digest/0/digest.rbs +110 -0
  186. data/stdlib/erb/0/erb.rbs +737 -347
  187. data/stdlib/fileutils/0/fileutils.rbs +20 -14
  188. data/stdlib/forwardable/0/forwardable.rbs +3 -0
  189. data/stdlib/json/0/json.rbs +82 -28
  190. data/stdlib/net-http/0/net-http.rbs +3 -0
  191. data/stdlib/objspace/0/objspace.rbs +9 -27
  192. data/stdlib/open-uri/0/open-uri.rbs +40 -0
  193. data/stdlib/open3/0/open3.rbs +459 -1
  194. data/stdlib/openssl/0/openssl.rbs +331 -228
  195. data/stdlib/optparse/0/optparse.rbs +8 -3
  196. data/stdlib/pathname/0/pathname.rbs +9 -1379
  197. data/stdlib/psych/0/psych.rbs +4 -4
  198. data/stdlib/random-formatter/0/random-formatter.rbs +277 -0
  199. data/stdlib/rdoc/0/code_object.rbs +2 -1
  200. data/stdlib/rdoc/0/parser.rbs +1 -1
  201. data/stdlib/rdoc/0/rdoc.rbs +1 -1
  202. data/stdlib/rdoc/0/store.rbs +1 -1
  203. data/stdlib/resolv/0/resolv.rbs +25 -68
  204. data/stdlib/ripper/0/ripper.rbs +2 -2
  205. data/stdlib/securerandom/0/manifest.yaml +2 -0
  206. data/stdlib/securerandom/0/securerandom.rbs +6 -19
  207. data/stdlib/singleton/0/singleton.rbs +3 -0
  208. data/stdlib/socket/0/socket.rbs +13 -1
  209. data/stdlib/socket/0/tcp_socket.rbs +10 -2
  210. data/stdlib/stringio/0/stringio.rbs +1176 -85
  211. data/stdlib/strscan/0/string_scanner.rbs +31 -31
  212. data/stdlib/tempfile/0/tempfile.rbs +3 -3
  213. data/stdlib/time/0/time.rbs +1 -1
  214. data/stdlib/timeout/0/timeout.rbs +63 -7
  215. data/stdlib/tsort/0/cyclic.rbs +3 -0
  216. data/stdlib/uri/0/common.rbs +16 -2
  217. data/stdlib/uri/0/file.rbs +1 -1
  218. data/stdlib/uri/0/generic.rbs +24 -16
  219. data/stdlib/uri/0/rfc2396_parser.rbs +6 -7
  220. data/stdlib/zlib/0/gzip_reader.rbs +2 -2
  221. data/stdlib/zlib/0/gzip_writer.rbs +1 -1
  222. data/stdlib/zlib/0/zstream.rbs +1 -0
  223. metadata +30 -4
data/core/float.rbs CHANGED
@@ -1,15 +1,193 @@
1
- # <!-- rdoc-file=numeric.c -->
2
- # A Float object represents a sometimes-inexact real number using the native
3
- # architecture's double-precision floating point representation.
1
+ # <!-- rdoc-file=float.rb -->
2
+ # A Float object stores a real number using the native architecture's
3
+ # double-precision floating-point representation.
4
+ #
5
+ # ## Float Imprecisions
6
+ #
7
+ # Some real numbers can be represented precisely as Float objects:
8
+ #
9
+ # 37.5 # => 37.5
10
+ # 98.75 # => 98.75
11
+ # 12.3125 # => 12.3125
12
+ #
13
+ # Others cannot; among these are the transcendental numbers, including:
14
+ #
15
+ # * Pi, *π*: in mathematics, a number of infinite precision:
16
+ # 3.1415926535897932384626433... (to 25 places); in Ruby, it is of limited
17
+ # precision (in this case, to 16 decimal places):
18
+ #
19
+ # Math::PI # => 3.141592653589793
20
+ #
21
+ # * Euler's number, *e*: in mathematics, a number of infinite precision:
22
+ # 2.7182818284590452353602874... (to 25 places); in Ruby, it is of limited
23
+ # precision (in this case, to 15 decimal places):
24
+ #
25
+ # Math::E # => 2.718281828459045
26
+ #
27
+ # Some floating-point computations in Ruby give precise results:
28
+ #
29
+ # 1.0/2 # => 0.5
30
+ # 100.0/8 # => 12.5
31
+ #
32
+ # Others do not:
33
+ #
34
+ # * In mathematics, 2/3 as a decimal number is an infinitely-repeating
35
+ # decimal: 0.666... (forever); in Ruby, `2.0/3` is of limited precision (in
36
+ # this case, to 16 decimal places):
37
+ #
38
+ # 2.0/3 # => 0.6666666666666666
39
+ #
40
+ # * In mathematics, the square root of 2 is an irrational number of infinite
41
+ # precision: 1.4142135623730950488016887... (to 25 decimal places); in Ruby,
42
+ # it is of limited precision (in this case, to 16 decimal places):
43
+ #
44
+ # Math.sqrt(2.0) # => 1.4142135623730951
45
+ #
46
+ # * Even a simple computation can introduce imprecision:
47
+ #
48
+ # x = 0.1 + 0.2 # => 0.30000000000000004
49
+ # y = 0.3 # => 0.3
50
+ # x == y # => false
51
+ #
52
+ # See:
53
+ #
54
+ # * https://docs.oracle.com/cd/E19957-01/806-3568/ncg_goldberg.html
55
+ # * https://github.com/rdp/ruby_tutorials_core/wiki/Ruby-Talk-FAQ#-why-are-rub
56
+ # ys-floats-imprecise
57
+ # * https://en.wikipedia.org/wiki/Floating_point#Accuracy_problems
58
+ #
59
+ # Note that precise storage and computation of rational numbers is possible
60
+ # using Rational objects.
61
+ #
62
+ # ## Creating a Float
63
+ #
64
+ # You can create a Float object explicitly with:
65
+ #
66
+ # * A [floating-point literal](rdoc-ref:syntax/literals.rdoc@Float+Literals).
67
+ #
68
+ # You can convert certain objects to Floats with:
69
+ #
70
+ # * Method #Float.
71
+ #
72
+ # ## What's Here
73
+ #
74
+ # First, what's elsewhere. Class Float:
75
+ #
76
+ # * Inherits from [class Numeric](rdoc-ref:Numeric@What-27s+Here) and [class
77
+ # Object](rdoc-ref:Object@What-27s+Here).
78
+ # * Includes [module Comparable](rdoc-ref:Comparable@What-27s+Here).
79
+ #
80
+ # Here, class Float provides methods for:
81
+ #
82
+ # * [Querying](rdoc-ref:Float@Querying)
83
+ # * [Comparing](rdoc-ref:Float@Comparing)
84
+ # * [Converting](rdoc-ref:Float@Converting)
85
+ #
86
+ # ### Querying
87
+ #
88
+ # * #finite?: Returns whether `self` is finite.
89
+ # * #hash: Returns the integer hash code for `self`.
90
+ # * #infinite?: Returns whether `self` is infinite.
91
+ # * #nan?: Returns whether `self` is a NaN (not-a-number).
92
+ #
93
+ # ### Comparing
94
+ #
95
+ # * #<: Returns whether `self` is less than the given value.
96
+ # * #<=: Returns whether `self` is less than or equal to the given value.
97
+ # * #<=>: Returns a number indicating whether `self` is less than, equal to,
98
+ # or greater than the given value.
99
+ # * #== (aliased as #=== and #eql?): Returns whether `self` is equal to the
100
+ # given value.
101
+ # * #>: Returns whether `self` is greater than the given value.
102
+ # * #>=: Returns whether `self` is greater than or equal to the given value.
103
+ #
104
+ # ### Converting
4
105
  #
5
- # Floating point has a different arithmetic and is an inexact number. So you
6
- # should know its esoteric system. See following:
106
+ # * #% (aliased as #modulo): Returns `self` modulo the given value.
107
+ # * #*: Returns the product of `self` and the given value.
108
+ # * #**: Returns the value of `self` raised to the power of the given value.
109
+ # * #+: Returns the sum of `self` and the given value.
110
+ # * #-: Returns the difference of `self` and the given value.
111
+ # * #/: Returns the quotient of `self` and the given value.
112
+ # * #ceil: Returns the smallest number greater than or equal to `self`.
113
+ # * #coerce: Returns a 2-element array containing the given value converted to
114
+ # a Float and `self`
115
+ # * #divmod: Returns a 2-element array containing the quotient and remainder
116
+ # results of dividing `self` by the given value.
117
+ # * #fdiv: Returns the Float result of dividing `self` by the given value.
118
+ # * #floor: Returns the greatest number smaller than or equal to `self`.
119
+ # * #next_float: Returns the next-larger representable Float.
120
+ # * #prev_float: Returns the next-smaller representable Float.
121
+ # * #quo: Returns the quotient from dividing `self` by the given value.
122
+ # * #round: Returns `self` rounded to the nearest value, to a given precision.
123
+ # * #to_i (aliased as #to_int): Returns `self` truncated to an Integer.
124
+ # * #to_s (aliased as #inspect): Returns a string containing the place-value
125
+ # representation of `self` in the given radix.
126
+ # * #truncate: Returns `self` truncated to a given precision.
127
+ #
128
+ # <!-- rdoc-file=float.rb -->
129
+ # A Float object stores a real number using the native architecture's
130
+ # double-precision floating-point representation.
131
+ #
132
+ # ## Float Imprecisions
133
+ #
134
+ # Some real numbers can be represented precisely as Float objects:
135
+ #
136
+ # 37.5 # => 37.5
137
+ # 98.75 # => 98.75
138
+ # 12.3125 # => 12.3125
139
+ #
140
+ # Others cannot; among these are the transcendental numbers, including:
141
+ #
142
+ # * Pi, *π*: in mathematics, a number of infinite precision:
143
+ # 3.1415926535897932384626433... (to 25 places); in Ruby, it is of limited
144
+ # precision (in this case, to 16 decimal places):
145
+ #
146
+ # Math::PI # => 3.141592653589793
147
+ #
148
+ # * Euler's number, *e*: in mathematics, a number of infinite precision:
149
+ # 2.7182818284590452353602874... (to 25 places); in Ruby, it is of limited
150
+ # precision (in this case, to 15 decimal places):
151
+ #
152
+ # Math::E # => 2.718281828459045
153
+ #
154
+ # Some floating-point computations in Ruby give precise results:
155
+ #
156
+ # 1.0/2 # => 0.5
157
+ # 100.0/8 # => 12.5
158
+ #
159
+ # Others do not:
160
+ #
161
+ # * In mathematics, 2/3 as a decimal number is an infinitely-repeating
162
+ # decimal: 0.666... (forever); in Ruby, `2.0/3` is of limited precision (in
163
+ # this case, to 16 decimal places):
164
+ #
165
+ # 2.0/3 # => 0.6666666666666666
166
+ #
167
+ # * In mathematics, the square root of 2 is an irrational number of infinite
168
+ # precision: 1.4142135623730950488016887... (to 25 decimal places); in Ruby,
169
+ # it is of limited precision (in this case, to 16 decimal places):
170
+ #
171
+ # Math.sqrt(2.0) # => 1.4142135623730951
172
+ #
173
+ # * Even a simple computation can introduce imprecision:
174
+ #
175
+ # x = 0.1 + 0.2 # => 0.30000000000000004
176
+ # y = 0.3 # => 0.3
177
+ # x == y # => false
178
+ #
179
+ # See:
7
180
  #
8
181
  # * https://docs.oracle.com/cd/E19957-01/806-3568/ncg_goldberg.html
9
182
  # * https://github.com/rdp/ruby_tutorials_core/wiki/Ruby-Talk-FAQ#-why-are-rub
10
183
  # ys-floats-imprecise
11
184
  # * https://en.wikipedia.org/wiki/Floating_point#Accuracy_problems
12
185
  #
186
+ # Note that precise storage and computation of rational numbers is possible
187
+ # using Rational objects.
188
+ #
189
+ # ## Creating a Float
190
+ #
13
191
  # You can create a Float object explicitly with:
14
192
  #
15
193
  # * A [floating-point literal](rdoc-ref:syntax/literals.rdoc@Float+Literals).
@@ -79,7 +257,7 @@ class Float < Numeric
79
257
  # rdoc-file=numeric.c
80
258
  # - self % other -> float
81
259
  # -->
82
- # Returns `self` modulo `other` as a float.
260
+ # Returns `self` modulo `other` as a Float.
83
261
  #
84
262
  # For float `f` and real number `r`, these expressions are equivalent:
85
263
  #
@@ -111,7 +289,7 @@ class Float < Numeric
111
289
  # rdoc-file=numeric.c
112
290
  # - self * other -> numeric
113
291
  # -->
114
- # Returns a new Float which is the product of `self` and `other`:
292
+ # Returns the numeric product of `self` and `other`:
115
293
  #
116
294
  # f = 3.14
117
295
  # f * 2 # => 6.28
@@ -124,9 +302,9 @@ class Float < Numeric
124
302
 
125
303
  # <!--
126
304
  # rdoc-file=numeric.c
127
- # - self ** other -> numeric
305
+ # - self ** exponent -> numeric
128
306
  # -->
129
- # Raises `self` to the power of `other`:
307
+ # Returns `self` raised to the power `exponent`:
130
308
  #
131
309
  # f = 3.14
132
310
  # f ** 2 # => 9.8596
@@ -140,26 +318,29 @@ class Float < Numeric
140
318
 
141
319
  # <!--
142
320
  # rdoc-file=numeric.c
143
- # - self + other -> numeric
321
+ # - self + other -> float or complex
144
322
  # -->
145
- # Returns a new Float which is the sum of `self` and `other`:
323
+ # Returns the sum of `self` and `other`; the result may be inexact (see Float):
146
324
  #
147
- # f = 3.14
148
- # f + 1 # => 4.140000000000001
149
- # f + 1.0 # => 4.140000000000001
150
- # f + Rational(1, 1) # => 4.140000000000001
151
- # f + Complex(1, 0) # => (4.140000000000001+0i)
325
+ # 3.14 + 0 # => 3.14
326
+ # 3.14 + 1 # => 4.140000000000001
327
+ # -3.14 + 0 # => -3.14
328
+ # -3.14 + 1 # => -2.14
329
+ #
330
+ # 3.14 + -3.14 # => 0.0
331
+ # -3.14 + -3.14 # => -6.28
332
+ #
333
+ # 3.14 + Complex(1, 0) # => (4.140000000000001+0i)
334
+ # 3.14 + Rational(1, 1) # => 4.140000000000001
152
335
  #
153
336
  def +: (Complex) -> Complex
154
337
  | (Numeric) -> Float
155
338
 
156
- def +@: () -> Float
157
-
158
339
  # <!--
159
340
  # rdoc-file=numeric.c
160
341
  # - self - other -> numeric
161
342
  # -->
162
- # Returns a new Float which is the difference of `self` and `other`:
343
+ # Returns the difference of `self` and `other`:
163
344
  #
164
345
  # f = 3.14
165
346
  # f - 1 # => 2.14
@@ -172,9 +353,13 @@ class Float < Numeric
172
353
 
173
354
  # <!--
174
355
  # rdoc-file=numeric.rb
175
- # - -float -> float
356
+ # - -self -> float
176
357
  # -->
177
- # Returns `self`, negated.
358
+ # Returns `self`, negated:
359
+ #
360
+ # -3.14 # => -3.14
361
+ # -(-3.14) # => 3.14
362
+ # -0.0 # => -0.0
178
363
  #
179
364
  def -@: () -> Float
180
365
 
@@ -182,7 +367,7 @@ class Float < Numeric
182
367
  # rdoc-file=numeric.c
183
368
  # - self / other -> numeric
184
369
  # -->
185
- # Returns a new Float which is the result of dividing `self` by `other`:
370
+ # Returns the quotient of `self` and `other`:
186
371
  #
187
372
  # f = 3.14
188
373
  # f / 2 # => 1.57
@@ -197,7 +382,8 @@ class Float < Numeric
197
382
  # rdoc-file=numeric.c
198
383
  # - self < other -> true or false
199
384
  # -->
200
- # Returns `true` if `self` is numerically less than `other`:
385
+ # Returns whether the value of `self` is less than the value of `other`; `other`
386
+ # must be numeric, but may not be Complex:
201
387
  #
202
388
  # 2.0 < 3 # => true
203
389
  # 2.0 < 3.0 # => true
@@ -212,7 +398,8 @@ class Float < Numeric
212
398
  # rdoc-file=numeric.c
213
399
  # - self <= other -> true or false
214
400
  # -->
215
- # Returns `true` if `self` is numerically less than or equal to `other`:
401
+ # Returns whether the value of `self` is less than or equal to the value of
402
+ # `other`; `other` must be numeric, but may not be Complex:
216
403
  #
217
404
  # 2.0 <= 3 # => true
218
405
  # 2.0 <= 3.0 # => true
@@ -226,30 +413,32 @@ class Float < Numeric
226
413
 
227
414
  # <!--
228
415
  # rdoc-file=numeric.c
229
- # - self <=> other -> -1, 0, +1, or nil
416
+ # - self <=> other -> -1, 0, 1, or nil
230
417
  # -->
231
- # Returns a value that depends on the numeric relation between `self` and
232
- # `other`:
418
+ # Compares `self` and `other`.
233
419
  #
234
- # * -1, if `self` is less than `other`.
235
- # * 0, if `self` is equal to `other`.
236
- # * 1, if `self` is greater than `other`.
420
+ # Returns:
421
+ #
422
+ # * `-1`, if `self` is less than `other`.
423
+ # * `0`, if `self` is equal to `other`.
424
+ # * `1`, if `self` is greater than `other`.
237
425
  # * `nil`, if the two values are incommensurate.
238
426
  #
239
427
  # Examples:
240
428
  #
429
+ # 2.0 <=> 2.1 # => -1
241
430
  # 2.0 <=> 2 # => 0
242
431
  # 2.0 <=> 2.0 # => 0
243
432
  # 2.0 <=> Rational(2, 1) # => 0
244
433
  # 2.0 <=> Complex(2, 0) # => 0
245
434
  # 2.0 <=> 1.9 # => 1
246
- # 2.0 <=> 2.1 # => -1
247
435
  # 2.0 <=> 'foo' # => nil
248
436
  #
249
- # This is the basis for the tests in the Comparable module.
250
- #
251
437
  # `Float::NAN <=> Float::NAN` returns an implementation-dependent value.
252
438
  #
439
+ # Class Float includes module Comparable, each of whose methods uses Float#<=>
440
+ # for comparison.
441
+ #
253
442
  def <=>: (Numeric) -> Integer?
254
443
 
255
444
  # <!--
@@ -326,12 +515,10 @@ class Float < Numeric
326
515
  #
327
516
  def abs: () -> Float
328
517
 
329
- def abs2: () -> Float
330
-
331
518
  # <!-- rdoc-file=complex.c -->
332
519
  # Returns 0 if `self` is positive, Math::PI otherwise.
333
520
  #
334
- def angle: () -> (Integer | Float)
521
+ def angle: ...
335
522
 
336
523
  # <!--
337
524
  # rdoc-file=complex.c
@@ -419,10 +606,6 @@ class Float < Numeric
419
606
  #
420
607
  def coerce: (Numeric) -> [ Float, Float ]
421
608
 
422
- def conj: () -> Float
423
-
424
- def conjugate: () -> Float
425
-
426
609
  # <!--
427
610
  # rdoc-file=rational.c
428
611
  # - flo.denominator -> integer
@@ -433,8 +616,6 @@ class Float < Numeric
433
616
  #
434
617
  def denominator: () -> Integer
435
618
 
436
- def div: (Numeric) -> Integer
437
-
438
619
  # <!--
439
620
  # rdoc-file=numeric.c
440
621
  # - divmod(other) -> array
@@ -462,8 +643,6 @@ class Float < Numeric
462
643
  def divmod: (Integer | Float | Rational) -> [ Integer, Float ]
463
644
  | (Numeric) -> [ Numeric, Numeric ]
464
645
 
465
- def dup: () -> self
466
-
467
646
  # <!--
468
647
  # rdoc-file=numeric.c
469
648
  # - eql?(other) -> true or false
@@ -586,12 +765,6 @@ class Float < Numeric
586
765
  #
587
766
  def hash: () -> Integer
588
767
 
589
- def i: () -> Complex
590
-
591
- def imag: () -> Integer
592
-
593
- def imaginary: () -> Integer
594
-
595
768
  # <!--
596
769
  # rdoc-file=numeric.c
597
770
  # - infinite? -> -1, 1, or nil
@@ -636,8 +809,6 @@ class Float < Numeric
636
809
  #
637
810
  alias inspect to_s
638
811
 
639
- def integer?: () -> bool
640
-
641
812
  # <!--
642
813
  # rdoc-file=numeric.rb
643
814
  # - magnitude()
@@ -646,7 +817,7 @@ class Float < Numeric
646
817
  alias magnitude abs
647
818
 
648
819
  # <!-- rdoc-file=numeric.c -->
649
- # Returns `self` modulo `other` as a float.
820
+ # Returns `self` modulo `other` as a Float.
650
821
  #
651
822
  # For float `f` and real number `r`, these expressions are equivalent:
652
823
  #
@@ -737,8 +908,6 @@ class Float < Numeric
737
908
  #
738
909
  def next_float: () -> Float
739
910
 
740
- def nonzero?: () -> self?
741
-
742
911
  # <!--
743
912
  # rdoc-file=rational.c
744
913
  # - flo.numerator -> integer
@@ -835,14 +1004,8 @@ class Float < Numeric
835
1004
  #
836
1005
  def rationalize: (?Numeric eps) -> Rational
837
1006
 
838
- def real: () -> Float
839
-
840
- def real?: () -> true
841
-
842
1007
  def rect: () -> [ Float, Numeric ]
843
1008
 
844
- alias rectangular rect
845
-
846
1009
  def remainder: (Numeric) -> Float
847
1010
 
848
1011
  # <!--
@@ -900,13 +1063,6 @@ class Float < Numeric
900
1063
  def round: (?half: :up | :down | :even) -> Integer
901
1064
  | (int digits, ?half: :up | :down | :even) -> (Integer | Float)
902
1065
 
903
- def step: (?Numeric limit, ?Numeric step) { (Float) -> void } -> self
904
- | (?Numeric limit, ?Numeric step) -> Enumerator[Float, self]
905
- | (?by: Numeric, ?to: Numeric) { (Float) -> void } -> self
906
- | (?by: Numeric, ?to: Numeric) -> Enumerator[Float, self]
907
-
908
- def to_c: () -> Complex
909
-
910
1066
  # <!--
911
1067
  # rdoc-file=numeric.rb
912
1068
  # - to_f -> self
@@ -1094,7 +1250,7 @@ Float::MAX_EXP: Integer
1094
1250
  # Usually defaults to 2.2250738585072014e-308.
1095
1251
  #
1096
1252
  # If the platform supports denormalized numbers, there are numbers between zero
1097
- # and Float::MIN. 0.0.next_float returns the smallest positive floating point
1253
+ # and Float::MIN. `0.0.next_float` returns the smallest positive floating point
1098
1254
  # number including denormalized numbers.
1099
1255
  #
1100
1256
  Float::MIN: Float