steep 0.16.0 → 0.16.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitmodules +0 -3
- data/CHANGELOG.md +6 -0
- data/Rakefile +0 -13
- data/bin/setup +0 -2
- data/bin/smoke_runner.rb +0 -1
- data/exe/steep +0 -1
- data/lib/steep/project/file.rb +1 -1
- data/lib/steep/project/hover_content.rb +1 -1
- data/lib/steep/server/code_worker.rb +1 -1
- data/lib/steep/server/signature_worker.rb +4 -4
- data/lib/steep/type_construction.rb +10 -16
- data/lib/steep/type_inference/constant_env.rb +2 -10
- data/lib/steep/type_inference/context.rb +1 -0
- data/lib/steep/version.rb +1 -1
- data/steep.gemspec +1 -5
- metadata +17 -135
- data/exe/rbs +0 -3
- data/vendor/ruby-signature/.github/workflows/ruby.yml +0 -27
- data/vendor/ruby-signature/.gitignore +0 -12
- data/vendor/ruby-signature/.rubocop.yml +0 -15
- data/vendor/ruby-signature/BSDL +0 -22
- data/vendor/ruby-signature/COPYING +0 -56
- data/vendor/ruby-signature/Gemfile +0 -6
- data/vendor/ruby-signature/README.md +0 -93
- data/vendor/ruby-signature/Rakefile +0 -142
- data/vendor/ruby-signature/bin/annotate-with-rdoc +0 -157
- data/vendor/ruby-signature/bin/console +0 -14
- data/vendor/ruby-signature/bin/query-rdoc +0 -103
- data/vendor/ruby-signature/bin/setup +0 -10
- data/vendor/ruby-signature/bin/sort +0 -89
- data/vendor/ruby-signature/bin/test_runner.rb +0 -16
- data/vendor/ruby-signature/docs/CONTRIBUTING.md +0 -97
- data/vendor/ruby-signature/docs/sigs.md +0 -148
- data/vendor/ruby-signature/docs/stdlib.md +0 -152
- data/vendor/ruby-signature/docs/syntax.md +0 -528
- data/vendor/ruby-signature/exe/rbs +0 -7
- data/vendor/ruby-signature/lib/rbs.rb +0 -64
- data/vendor/ruby-signature/lib/rbs/ast/annotation.rb +0 -27
- data/vendor/ruby-signature/lib/rbs/ast/comment.rb +0 -27
- data/vendor/ruby-signature/lib/rbs/ast/declarations.rb +0 -395
- data/vendor/ruby-signature/lib/rbs/ast/members.rb +0 -362
- data/vendor/ruby-signature/lib/rbs/buffer.rb +0 -50
- data/vendor/ruby-signature/lib/rbs/builtin_names.rb +0 -55
- data/vendor/ruby-signature/lib/rbs/cli.rb +0 -558
- data/vendor/ruby-signature/lib/rbs/constant.rb +0 -26
- data/vendor/ruby-signature/lib/rbs/constant_table.rb +0 -150
- data/vendor/ruby-signature/lib/rbs/definition.rb +0 -170
- data/vendor/ruby-signature/lib/rbs/definition_builder.rb +0 -919
- data/vendor/ruby-signature/lib/rbs/environment.rb +0 -281
- data/vendor/ruby-signature/lib/rbs/environment_loader.rb +0 -136
- data/vendor/ruby-signature/lib/rbs/environment_walker.rb +0 -124
- data/vendor/ruby-signature/lib/rbs/errors.rb +0 -187
- data/vendor/ruby-signature/lib/rbs/location.rb +0 -102
- data/vendor/ruby-signature/lib/rbs/method_type.rb +0 -123
- data/vendor/ruby-signature/lib/rbs/namespace.rb +0 -91
- data/vendor/ruby-signature/lib/rbs/parser.y +0 -1344
- data/vendor/ruby-signature/lib/rbs/prototype/rb.rb +0 -553
- data/vendor/ruby-signature/lib/rbs/prototype/rbi.rb +0 -587
- data/vendor/ruby-signature/lib/rbs/prototype/runtime.rb +0 -381
- data/vendor/ruby-signature/lib/rbs/substitution.rb +0 -46
- data/vendor/ruby-signature/lib/rbs/test.rb +0 -26
- data/vendor/ruby-signature/lib/rbs/test/errors.rb +0 -61
- data/vendor/ruby-signature/lib/rbs/test/hook.rb +0 -294
- data/vendor/ruby-signature/lib/rbs/test/setup.rb +0 -58
- data/vendor/ruby-signature/lib/rbs/test/spy.rb +0 -325
- data/vendor/ruby-signature/lib/rbs/test/test_helper.rb +0 -183
- data/vendor/ruby-signature/lib/rbs/test/type_check.rb +0 -254
- data/vendor/ruby-signature/lib/rbs/type_name.rb +0 -70
- data/vendor/ruby-signature/lib/rbs/types.rb +0 -936
- data/vendor/ruby-signature/lib/rbs/variance_calculator.rb +0 -138
- data/vendor/ruby-signature/lib/rbs/vendorer.rb +0 -47
- data/vendor/ruby-signature/lib/rbs/version.rb +0 -3
- data/vendor/ruby-signature/lib/rbs/writer.rb +0 -269
- data/vendor/ruby-signature/lib/ruby/signature.rb +0 -7
- data/vendor/ruby-signature/rbs.gemspec +0 -46
- data/vendor/ruby-signature/stdlib/abbrev/abbrev.rbs +0 -60
- data/vendor/ruby-signature/stdlib/base64/base64.rbs +0 -71
- data/vendor/ruby-signature/stdlib/benchmark/benchmark.rbs +0 -372
- data/vendor/ruby-signature/stdlib/builtin/array.rbs +0 -1997
- data/vendor/ruby-signature/stdlib/builtin/basic_object.rbs +0 -280
- data/vendor/ruby-signature/stdlib/builtin/binding.rbs +0 -177
- data/vendor/ruby-signature/stdlib/builtin/builtin.rbs +0 -45
- data/vendor/ruby-signature/stdlib/builtin/class.rbs +0 -145
- data/vendor/ruby-signature/stdlib/builtin/comparable.rbs +0 -116
- data/vendor/ruby-signature/stdlib/builtin/complex.rbs +0 -400
- data/vendor/ruby-signature/stdlib/builtin/constants.rbs +0 -37
- data/vendor/ruby-signature/stdlib/builtin/data.rbs +0 -5
- data/vendor/ruby-signature/stdlib/builtin/deprecated.rbs +0 -2
- data/vendor/ruby-signature/stdlib/builtin/dir.rbs +0 -413
- data/vendor/ruby-signature/stdlib/builtin/encoding.rbs +0 -607
- data/vendor/ruby-signature/stdlib/builtin/enumerable.rbs +0 -404
- data/vendor/ruby-signature/stdlib/builtin/enumerator.rbs +0 -260
- data/vendor/ruby-signature/stdlib/builtin/errno.rbs +0 -781
- data/vendor/ruby-signature/stdlib/builtin/errors.rbs +0 -582
- data/vendor/ruby-signature/stdlib/builtin/exception.rbs +0 -194
- data/vendor/ruby-signature/stdlib/builtin/false_class.rbs +0 -40
- data/vendor/ruby-signature/stdlib/builtin/fiber.rbs +0 -68
- data/vendor/ruby-signature/stdlib/builtin/fiber_error.rbs +0 -12
- data/vendor/ruby-signature/stdlib/builtin/file.rbs +0 -1076
- data/vendor/ruby-signature/stdlib/builtin/file_test.rbs +0 -59
- data/vendor/ruby-signature/stdlib/builtin/float.rbs +0 -696
- data/vendor/ruby-signature/stdlib/builtin/gc.rbs +0 -243
- data/vendor/ruby-signature/stdlib/builtin/hash.rbs +0 -1029
- data/vendor/ruby-signature/stdlib/builtin/integer.rbs +0 -707
- data/vendor/ruby-signature/stdlib/builtin/io.rbs +0 -683
- data/vendor/ruby-signature/stdlib/builtin/kernel.rbs +0 -576
- data/vendor/ruby-signature/stdlib/builtin/marshal.rbs +0 -161
- data/vendor/ruby-signature/stdlib/builtin/match_data.rbs +0 -271
- data/vendor/ruby-signature/stdlib/builtin/math.rbs +0 -369
- data/vendor/ruby-signature/stdlib/builtin/method.rbs +0 -185
- data/vendor/ruby-signature/stdlib/builtin/module.rbs +0 -1104
- data/vendor/ruby-signature/stdlib/builtin/nil_class.rbs +0 -82
- data/vendor/ruby-signature/stdlib/builtin/numeric.rbs +0 -409
- data/vendor/ruby-signature/stdlib/builtin/object.rbs +0 -824
- data/vendor/ruby-signature/stdlib/builtin/proc.rbs +0 -429
- data/vendor/ruby-signature/stdlib/builtin/process.rbs +0 -1227
- data/vendor/ruby-signature/stdlib/builtin/random.rbs +0 -267
- data/vendor/ruby-signature/stdlib/builtin/range.rbs +0 -226
- data/vendor/ruby-signature/stdlib/builtin/rational.rbs +0 -424
- data/vendor/ruby-signature/stdlib/builtin/rb_config.rbs +0 -57
- data/vendor/ruby-signature/stdlib/builtin/regexp.rbs +0 -1083
- data/vendor/ruby-signature/stdlib/builtin/ruby_vm.rbs +0 -14
- data/vendor/ruby-signature/stdlib/builtin/signal.rbs +0 -55
- data/vendor/ruby-signature/stdlib/builtin/string.rbs +0 -1901
- data/vendor/ruby-signature/stdlib/builtin/string_io.rbs +0 -284
- data/vendor/ruby-signature/stdlib/builtin/struct.rbs +0 -40
- data/vendor/ruby-signature/stdlib/builtin/symbol.rbs +0 -228
- data/vendor/ruby-signature/stdlib/builtin/thread.rbs +0 -1108
- data/vendor/ruby-signature/stdlib/builtin/thread_group.rbs +0 -23
- data/vendor/ruby-signature/stdlib/builtin/time.rbs +0 -1047
- data/vendor/ruby-signature/stdlib/builtin/trace_point.rbs +0 -290
- data/vendor/ruby-signature/stdlib/builtin/true_class.rbs +0 -46
- data/vendor/ruby-signature/stdlib/builtin/unbound_method.rbs +0 -153
- data/vendor/ruby-signature/stdlib/builtin/warning.rbs +0 -17
- data/vendor/ruby-signature/stdlib/coverage/coverage.rbs +0 -62
- data/vendor/ruby-signature/stdlib/csv/csv.rbs +0 -773
- data/vendor/ruby-signature/stdlib/erb/erb.rbs +0 -392
- data/vendor/ruby-signature/stdlib/find/find.rbs +0 -40
- data/vendor/ruby-signature/stdlib/ipaddr/ipaddr.rbs +0 -247
- data/vendor/ruby-signature/stdlib/json/json.rbs +0 -335
- data/vendor/ruby-signature/stdlib/pathname/pathname.rbs +0 -1093
- data/vendor/ruby-signature/stdlib/prime/integer-extension.rbs +0 -23
- data/vendor/ruby-signature/stdlib/prime/prime.rbs +0 -188
- data/vendor/ruby-signature/stdlib/securerandom/securerandom.rbs +0 -9
- data/vendor/ruby-signature/stdlib/set/set.rbs +0 -301
- data/vendor/ruby-signature/stdlib/tmpdir/tmpdir.rbs +0 -53
@@ -1,59 +0,0 @@
|
|
1
|
-
# `FileTest` implements file test operations similar to those used in
|
2
|
-
# `File::Stat` . It exists as a standalone module, and its methods are
|
3
|
-
# also insinuated into the `File` class. (Note that this is not done by
|
4
|
-
# inclusion: the interpreter cheats).
|
5
|
-
module FileTest
|
6
|
-
def self.blockdev?: (String | IO file_name) -> bool
|
7
|
-
|
8
|
-
def self.chardev?: (String | IO file_name) -> bool
|
9
|
-
|
10
|
-
def self.directory?: (String | IO file_name) -> bool
|
11
|
-
|
12
|
-
def self.empty?: (String | IO file_name) -> bool
|
13
|
-
|
14
|
-
def self.executable?: (String | IO file_name) -> bool
|
15
|
-
|
16
|
-
def self.executable_real?: (String | IO file_name) -> bool
|
17
|
-
|
18
|
-
def self.exist?: (String | IO file_name) -> bool
|
19
|
-
|
20
|
-
def self.exists?: (String | IO file_name) -> bool
|
21
|
-
|
22
|
-
def self.file?: (String | IO file) -> bool
|
23
|
-
|
24
|
-
def self.grpowned?: (String | IO file_name) -> bool
|
25
|
-
|
26
|
-
def self.identical?: (String | IO file_1, String | IO file_2) -> bool
|
27
|
-
|
28
|
-
def self.owned?: (String | IO file_name) -> bool
|
29
|
-
|
30
|
-
def self.pipe?: (String | IO file_name) -> bool
|
31
|
-
|
32
|
-
def self.readable?: (String | IO file_name) -> bool
|
33
|
-
|
34
|
-
def self.readable_real?: (String | IO file_name) -> bool
|
35
|
-
|
36
|
-
def self.setgid?: (String | IO file_name) -> bool
|
37
|
-
|
38
|
-
def self.setuid?: (String | IO file_name) -> bool
|
39
|
-
|
40
|
-
def self.size: (String | IO file_name) -> Integer
|
41
|
-
|
42
|
-
def self.size?: (String | IO file_name) -> Integer?
|
43
|
-
|
44
|
-
def self.socket?: (String | IO file_name) -> bool
|
45
|
-
|
46
|
-
def self.sticky?: (String | IO file_name) -> bool
|
47
|
-
|
48
|
-
def self.symlink?: (String | IO file_name) -> bool
|
49
|
-
|
50
|
-
def self.world_readable?: (String | IO file_name) -> Integer?
|
51
|
-
|
52
|
-
def self.world_writable?: (String | IO file_name) -> Integer?
|
53
|
-
|
54
|
-
def self.writable?: (String | IO file_name) -> bool
|
55
|
-
|
56
|
-
def self.writable_real?: (String | IO file_name) -> bool
|
57
|
-
|
58
|
-
def self.zero?: (String | IO file_name) -> bool
|
59
|
-
end
|
@@ -1,696 +0,0 @@
|
|
1
|
-
# Float objects represent inexact real numbers using the native architecture's
|
2
|
-
# double-precision floating point representation.
|
3
|
-
#
|
4
|
-
# Floating point has a different arithmetic and is an inexact number. So you
|
5
|
-
# should know its esoteric system. See following:
|
6
|
-
#
|
7
|
-
# * http://docs.sun.com/source/806-3568/ncg_goldberg.html
|
8
|
-
# * https://github.com/rdp/ruby_tutorials_core/wiki/Ruby-Talk-FAQ#floats_impre
|
9
|
-
# cise
|
10
|
-
# * http://en.wikipedia.org/wiki/Floating_point#Accuracy_problems
|
11
|
-
#
|
12
|
-
#
|
13
|
-
class Float < Numeric
|
14
|
-
public
|
15
|
-
|
16
|
-
# Returns the modulo after division of `float` by `other`.
|
17
|
-
#
|
18
|
-
# 6543.21.modulo(137) #=> 104.21000000000004
|
19
|
-
# 6543.21.modulo(137.24) #=> 92.92999999999961
|
20
|
-
#
|
21
|
-
def %: (Integer) -> Float
|
22
|
-
| (Float) -> Float
|
23
|
-
| (Rational) -> Float
|
24
|
-
| (Numeric) -> Numeric
|
25
|
-
|
26
|
-
# Returns a new Float which is the product of `float` and `other`.
|
27
|
-
#
|
28
|
-
def *: (Complex) -> Complex
|
29
|
-
| (Numeric) -> Float
|
30
|
-
|
31
|
-
# Raises `float` to the power of `other`.
|
32
|
-
#
|
33
|
-
# 2.0**3 #=> 8.0
|
34
|
-
#
|
35
|
-
def **: (Complex) -> Complex
|
36
|
-
| (Numeric) -> Float
|
37
|
-
|
38
|
-
# Returns a new Float which is the sum of `float` and `other`.
|
39
|
-
#
|
40
|
-
def +: (Complex) -> Complex
|
41
|
-
| (Numeric) -> Float
|
42
|
-
|
43
|
-
def +@: () -> Float
|
44
|
-
|
45
|
-
# Returns a new Float which is the difference of `float` and `other`.
|
46
|
-
#
|
47
|
-
def -: (Complex) -> Complex
|
48
|
-
| (Numeric) -> Float
|
49
|
-
|
50
|
-
# Returns `float`, negated.
|
51
|
-
#
|
52
|
-
def -@: () -> Float
|
53
|
-
|
54
|
-
# Returns a new Float which is the result of dividing `float` by `other`.
|
55
|
-
#
|
56
|
-
def /: (Complex) -> Complex
|
57
|
-
| (Numeric) -> Float
|
58
|
-
|
59
|
-
# Returns `true` if `float` is less than `real`.
|
60
|
-
#
|
61
|
-
# The result of `NaN < NaN` is undefined, so an implementation-dependent value
|
62
|
-
# is returned.
|
63
|
-
#
|
64
|
-
def <: (Numeric) -> bool
|
65
|
-
|
66
|
-
# Returns `true` if `float` is less than or equal to `real`.
|
67
|
-
#
|
68
|
-
# The result of `NaN <= NaN` is undefined, so an implementation-dependent value
|
69
|
-
# is returned.
|
70
|
-
#
|
71
|
-
def <=: (Numeric) -> bool
|
72
|
-
|
73
|
-
# Returns -1, 0, or +1 depending on whether `float` is less than, equal to, or
|
74
|
-
# greater than `real`. This is the basis for the tests in the Comparable module.
|
75
|
-
#
|
76
|
-
# The result of `NaN <=> NaN` is undefined, so an implementation-dependent value
|
77
|
-
# is returned.
|
78
|
-
#
|
79
|
-
# `nil` is returned if the two values are incomparable.
|
80
|
-
#
|
81
|
-
def <=>: (Numeric) -> Integer?
|
82
|
-
|
83
|
-
# Returns `true` only if `obj` has the same value as `float`. Contrast this with
|
84
|
-
# Float#eql?, which requires `obj` to be a Float.
|
85
|
-
#
|
86
|
-
# 1.0 == 1 #=> true
|
87
|
-
#
|
88
|
-
# The result of `NaN == NaN` is undefined, so an implementation-dependent value
|
89
|
-
# is returned.
|
90
|
-
#
|
91
|
-
def ==: (untyped) -> bool
|
92
|
-
|
93
|
-
# Returns `true` only if `obj` has the same value as `float`. Contrast this with
|
94
|
-
# Float#eql?, which requires `obj` to be a Float.
|
95
|
-
#
|
96
|
-
# 1.0 == 1 #=> true
|
97
|
-
#
|
98
|
-
# The result of `NaN == NaN` is undefined, so an implementation-dependent value
|
99
|
-
# is returned.
|
100
|
-
#
|
101
|
-
def ===: (untyped) -> bool
|
102
|
-
|
103
|
-
# Returns `true` if `float` is greater than `real`.
|
104
|
-
#
|
105
|
-
# The result of `NaN > NaN` is undefined, so an implementation-dependent value
|
106
|
-
# is returned.
|
107
|
-
#
|
108
|
-
def >: (Numeric) -> bool
|
109
|
-
|
110
|
-
# Returns `true` if `float` is greater than or equal to `real`.
|
111
|
-
#
|
112
|
-
# The result of `NaN >= NaN` is undefined, so an implementation-dependent value
|
113
|
-
# is returned.
|
114
|
-
#
|
115
|
-
def >=: (Numeric) -> bool
|
116
|
-
|
117
|
-
# Returns the absolute value of `float`.
|
118
|
-
#
|
119
|
-
# (-34.56).abs #=> 34.56
|
120
|
-
# -34.56.abs #=> 34.56
|
121
|
-
# 34.56.abs #=> 34.56
|
122
|
-
#
|
123
|
-
# Float#magnitude is an alias for Float#abs.
|
124
|
-
#
|
125
|
-
def abs: () -> Float
|
126
|
-
|
127
|
-
def abs2: () -> Float
|
128
|
-
|
129
|
-
# Returns 0 if the value is positive, pi otherwise.
|
130
|
-
#
|
131
|
-
def angle: () -> (Integer | Float)
|
132
|
-
|
133
|
-
# Returns 0 if the value is positive, pi otherwise.
|
134
|
-
#
|
135
|
-
alias arg angle
|
136
|
-
|
137
|
-
# Returns the smallest number greater than or equal to `float` with a precision
|
138
|
-
# of `ndigits` decimal digits (default: 0).
|
139
|
-
#
|
140
|
-
# When the precision is negative, the returned value is an integer with at least
|
141
|
-
# `ndigits.abs` trailing zeros.
|
142
|
-
#
|
143
|
-
# Returns a floating point number when `ndigits` is positive, otherwise returns
|
144
|
-
# an integer.
|
145
|
-
#
|
146
|
-
# 1.2.ceil #=> 2
|
147
|
-
# 2.0.ceil #=> 2
|
148
|
-
# (-1.2).ceil #=> -1
|
149
|
-
# (-2.0).ceil #=> -2
|
150
|
-
#
|
151
|
-
# 1.234567.ceil(2) #=> 1.24
|
152
|
-
# 1.234567.ceil(3) #=> 1.235
|
153
|
-
# 1.234567.ceil(4) #=> 1.2346
|
154
|
-
# 1.234567.ceil(5) #=> 1.23457
|
155
|
-
#
|
156
|
-
# 34567.89.ceil(-5) #=> 100000
|
157
|
-
# 34567.89.ceil(-4) #=> 40000
|
158
|
-
# 34567.89.ceil(-3) #=> 35000
|
159
|
-
# 34567.89.ceil(-2) #=> 34600
|
160
|
-
# 34567.89.ceil(-1) #=> 34570
|
161
|
-
# 34567.89.ceil(0) #=> 34568
|
162
|
-
# 34567.89.ceil(1) #=> 34567.9
|
163
|
-
# 34567.89.ceil(2) #=> 34567.89
|
164
|
-
# 34567.89.ceil(3) #=> 34567.89
|
165
|
-
#
|
166
|
-
# Note that the limited precision of floating point arithmetic might lead to
|
167
|
-
# surprising results:
|
168
|
-
#
|
169
|
-
# (2.1 / 0.7).ceil #=> 4 (!)
|
170
|
-
#
|
171
|
-
def ceil: () -> Integer
|
172
|
-
| (int digits) -> (Integer | Float)
|
173
|
-
|
174
|
-
def clone: (?freeze: bool) -> self
|
175
|
-
|
176
|
-
# Returns an array with both `numeric` and `float` represented as Float objects.
|
177
|
-
#
|
178
|
-
# This is achieved by converting `numeric` to a Float.
|
179
|
-
#
|
180
|
-
# 1.2.coerce(3) #=> [3.0, 1.2]
|
181
|
-
# 2.5.coerce(1.1) #=> [1.1, 2.5]
|
182
|
-
#
|
183
|
-
def coerce: (Numeric) -> [Numeric, Numeric]
|
184
|
-
|
185
|
-
def conj: () -> Float
|
186
|
-
|
187
|
-
def conjugate: () -> Float
|
188
|
-
|
189
|
-
# Returns the denominator (always positive). The result is machine dependent.
|
190
|
-
#
|
191
|
-
# See also Float#numerator.
|
192
|
-
#
|
193
|
-
def denominator: () -> Integer
|
194
|
-
|
195
|
-
def div: (Numeric) -> Integer
|
196
|
-
|
197
|
-
# See Numeric#divmod.
|
198
|
-
#
|
199
|
-
# 42.0.divmod(6) #=> [7, 0.0]
|
200
|
-
# 42.0.divmod(5) #=> [8, 2.0]
|
201
|
-
#
|
202
|
-
def divmod: (Numeric) -> [Numeric, Numeric]
|
203
|
-
|
204
|
-
def dup: () -> self
|
205
|
-
|
206
|
-
# Returns `true` only if `obj` is a Float with the same value as `float`.
|
207
|
-
# Contrast this with Float#==, which performs type conversions.
|
208
|
-
#
|
209
|
-
# 1.0.eql?(1) #=> false
|
210
|
-
#
|
211
|
-
# The result of `NaN.eql?(NaN)` is undefined, so an implementation-dependent
|
212
|
-
# value is returned.
|
213
|
-
#
|
214
|
-
def eql?: (untyped) -> bool
|
215
|
-
|
216
|
-
# Returns `float / numeric`, same as Float#/.
|
217
|
-
#
|
218
|
-
def fdiv: (Complex) -> Complex
|
219
|
-
| (Numeric) -> Float
|
220
|
-
|
221
|
-
# Returns `true` if `float` is a valid IEEE floating point number, i.e. it is
|
222
|
-
# not infinite and Float#nan? is `false`.
|
223
|
-
#
|
224
|
-
def finite?: () -> bool
|
225
|
-
|
226
|
-
# Returns the largest number less than or equal to `float` with a precision of
|
227
|
-
# `ndigits` decimal digits (default: 0).
|
228
|
-
#
|
229
|
-
# When the precision is negative, the returned value is an integer with at least
|
230
|
-
# `ndigits.abs` trailing zeros.
|
231
|
-
#
|
232
|
-
# Returns a floating point number when `ndigits` is positive, otherwise returns
|
233
|
-
# an integer.
|
234
|
-
#
|
235
|
-
# 1.2.floor #=> 1
|
236
|
-
# 2.0.floor #=> 2
|
237
|
-
# (-1.2).floor #=> -2
|
238
|
-
# (-2.0).floor #=> -2
|
239
|
-
#
|
240
|
-
# 1.234567.floor(2) #=> 1.23
|
241
|
-
# 1.234567.floor(3) #=> 1.234
|
242
|
-
# 1.234567.floor(4) #=> 1.2345
|
243
|
-
# 1.234567.floor(5) #=> 1.23456
|
244
|
-
#
|
245
|
-
# 34567.89.floor(-5) #=> 0
|
246
|
-
# 34567.89.floor(-4) #=> 30000
|
247
|
-
# 34567.89.floor(-3) #=> 34000
|
248
|
-
# 34567.89.floor(-2) #=> 34500
|
249
|
-
# 34567.89.floor(-1) #=> 34560
|
250
|
-
# 34567.89.floor(0) #=> 34567
|
251
|
-
# 34567.89.floor(1) #=> 34567.8
|
252
|
-
# 34567.89.floor(2) #=> 34567.89
|
253
|
-
# 34567.89.floor(3) #=> 34567.89
|
254
|
-
#
|
255
|
-
# Note that the limited precision of floating point arithmetic might lead to
|
256
|
-
# surprising results:
|
257
|
-
#
|
258
|
-
# (0.3 / 0.1).floor #=> 2 (!)
|
259
|
-
#
|
260
|
-
def floor: () -> Integer
|
261
|
-
| (int digits) -> (Integer | Numeric)
|
262
|
-
|
263
|
-
# Returns a hash code for this float.
|
264
|
-
#
|
265
|
-
# See also Object#hash.
|
266
|
-
#
|
267
|
-
def hash: () -> Integer
|
268
|
-
|
269
|
-
def i: () -> Complex
|
270
|
-
|
271
|
-
def imag: () -> Integer
|
272
|
-
|
273
|
-
def imaginary: () -> Integer
|
274
|
-
|
275
|
-
# Returns `nil`, -1, or 1 depending on whether the value is finite, `-Infinity`,
|
276
|
-
# or `+Infinity`.
|
277
|
-
#
|
278
|
-
# (0.0).infinite? #=> nil
|
279
|
-
# (-1.0/0.0).infinite? #=> -1
|
280
|
-
# (+1.0/0.0).infinite? #=> 1
|
281
|
-
#
|
282
|
-
def infinite?: () -> Integer?
|
283
|
-
|
284
|
-
alias inspect to_s
|
285
|
-
|
286
|
-
def integer?: () -> bool
|
287
|
-
|
288
|
-
# Returns the absolute value of `float`.
|
289
|
-
#
|
290
|
-
# (-34.56).abs #=> 34.56
|
291
|
-
# -34.56.abs #=> 34.56
|
292
|
-
# 34.56.abs #=> 34.56
|
293
|
-
#
|
294
|
-
# Float#magnitude is an alias for Float#abs.
|
295
|
-
#
|
296
|
-
alias magnitude abs
|
297
|
-
|
298
|
-
# Returns the modulo after division of `float` by `other`.
|
299
|
-
#
|
300
|
-
# 6543.21.modulo(137) #=> 104.21000000000004
|
301
|
-
# 6543.21.modulo(137.24) #=> 92.92999999999961
|
302
|
-
#
|
303
|
-
def modulo: (Numeric) -> Float
|
304
|
-
|
305
|
-
# Returns `true` if `float` is an invalid IEEE floating point number.
|
306
|
-
#
|
307
|
-
# a = -1.0 #=> -1.0
|
308
|
-
# a.nan? #=> false
|
309
|
-
# a = 0.0/0.0 #=> NaN
|
310
|
-
# a.nan? #=> true
|
311
|
-
#
|
312
|
-
def nan?: () -> bool
|
313
|
-
|
314
|
-
# Returns `true` if `float` is less than 0.
|
315
|
-
#
|
316
|
-
def negative?: () -> bool
|
317
|
-
|
318
|
-
# Returns the next representable floating point number.
|
319
|
-
#
|
320
|
-
# Float::MAX.next_float and Float::INFINITY.next_float is Float::INFINITY.
|
321
|
-
#
|
322
|
-
# Float::NAN.next_float is Float::NAN.
|
323
|
-
#
|
324
|
-
# For example:
|
325
|
-
#
|
326
|
-
# 0.01.next_float #=> 0.010000000000000002
|
327
|
-
# 1.0.next_float #=> 1.0000000000000002
|
328
|
-
# 100.0.next_float #=> 100.00000000000001
|
329
|
-
#
|
330
|
-
# 0.01.next_float - 0.01 #=> 1.734723475976807e-18
|
331
|
-
# 1.0.next_float - 1.0 #=> 2.220446049250313e-16
|
332
|
-
# 100.0.next_float - 100.0 #=> 1.4210854715202004e-14
|
333
|
-
#
|
334
|
-
# f = 0.01; 20.times { printf "%-20a %s\n", f, f.to_s; f = f.next_float }
|
335
|
-
# #=> 0x1.47ae147ae147bp-7 0.01
|
336
|
-
# # 0x1.47ae147ae147cp-7 0.010000000000000002
|
337
|
-
# # 0x1.47ae147ae147dp-7 0.010000000000000004
|
338
|
-
# # 0x1.47ae147ae147ep-7 0.010000000000000005
|
339
|
-
# # 0x1.47ae147ae147fp-7 0.010000000000000007
|
340
|
-
# # 0x1.47ae147ae148p-7 0.010000000000000009
|
341
|
-
# # 0x1.47ae147ae1481p-7 0.01000000000000001
|
342
|
-
# # 0x1.47ae147ae1482p-7 0.010000000000000012
|
343
|
-
# # 0x1.47ae147ae1483p-7 0.010000000000000014
|
344
|
-
# # 0x1.47ae147ae1484p-7 0.010000000000000016
|
345
|
-
# # 0x1.47ae147ae1485p-7 0.010000000000000018
|
346
|
-
# # 0x1.47ae147ae1486p-7 0.01000000000000002
|
347
|
-
# # 0x1.47ae147ae1487p-7 0.010000000000000021
|
348
|
-
# # 0x1.47ae147ae1488p-7 0.010000000000000023
|
349
|
-
# # 0x1.47ae147ae1489p-7 0.010000000000000024
|
350
|
-
# # 0x1.47ae147ae148ap-7 0.010000000000000026
|
351
|
-
# # 0x1.47ae147ae148bp-7 0.010000000000000028
|
352
|
-
# # 0x1.47ae147ae148cp-7 0.01000000000000003
|
353
|
-
# # 0x1.47ae147ae148dp-7 0.010000000000000031
|
354
|
-
# # 0x1.47ae147ae148ep-7 0.010000000000000033
|
355
|
-
#
|
356
|
-
# f = 0.0
|
357
|
-
# 100.times { f += 0.1 }
|
358
|
-
# f #=> 9.99999999999998 # should be 10.0 in the ideal world.
|
359
|
-
# 10-f #=> 1.9539925233402755e-14 # the floating point error.
|
360
|
-
# 10.0.next_float-10 #=> 1.7763568394002505e-15 # 1 ulp (unit in the last place).
|
361
|
-
# (10-f)/(10.0.next_float-10) #=> 11.0 # the error is 11 ulp.
|
362
|
-
# (10-f)/(10*Float::EPSILON) #=> 8.8 # approximation of the above.
|
363
|
-
# "%a" % 10 #=> "0x1.4p+3"
|
364
|
-
# "%a" % f #=> "0x1.3fffffffffff5p+3" # the last hex digit is 5. 16 - 5 = 11 ulp.
|
365
|
-
#
|
366
|
-
def next_float: () -> Float
|
367
|
-
|
368
|
-
def nonzero?: () -> self?
|
369
|
-
|
370
|
-
# Returns the numerator. The result is machine dependent.
|
371
|
-
#
|
372
|
-
# n = 0.3.numerator #=> 5404319552844595
|
373
|
-
# d = 0.3.denominator #=> 18014398509481984
|
374
|
-
# n.fdiv(d) #=> 0.3
|
375
|
-
#
|
376
|
-
# See also Float#denominator.
|
377
|
-
#
|
378
|
-
def numerator: () -> Integer
|
379
|
-
|
380
|
-
# Returns 0 if the value is positive, pi otherwise.
|
381
|
-
#
|
382
|
-
alias phase angle
|
383
|
-
|
384
|
-
def polar: () -> [ Float, Integer | Float ]
|
385
|
-
|
386
|
-
# Returns `true` if `float` is greater than 0.
|
387
|
-
#
|
388
|
-
def positive?: () -> bool
|
389
|
-
|
390
|
-
# Returns the previous representable floating point number.
|
391
|
-
#
|
392
|
-
# (-Float::MAX).prev_float and (-Float::INFINITY).prev_float is
|
393
|
-
# -Float::INFINITY.
|
394
|
-
#
|
395
|
-
# Float::NAN.prev_float is Float::NAN.
|
396
|
-
#
|
397
|
-
# For example:
|
398
|
-
#
|
399
|
-
# 0.01.prev_float #=> 0.009999999999999998
|
400
|
-
# 1.0.prev_float #=> 0.9999999999999999
|
401
|
-
# 100.0.prev_float #=> 99.99999999999999
|
402
|
-
#
|
403
|
-
# 0.01 - 0.01.prev_float #=> 1.734723475976807e-18
|
404
|
-
# 1.0 - 1.0.prev_float #=> 1.1102230246251565e-16
|
405
|
-
# 100.0 - 100.0.prev_float #=> 1.4210854715202004e-14
|
406
|
-
#
|
407
|
-
# f = 0.01; 20.times { printf "%-20a %s\n", f, f.to_s; f = f.prev_float }
|
408
|
-
# #=> 0x1.47ae147ae147bp-7 0.01
|
409
|
-
# # 0x1.47ae147ae147ap-7 0.009999999999999998
|
410
|
-
# # 0x1.47ae147ae1479p-7 0.009999999999999997
|
411
|
-
# # 0x1.47ae147ae1478p-7 0.009999999999999995
|
412
|
-
# # 0x1.47ae147ae1477p-7 0.009999999999999993
|
413
|
-
# # 0x1.47ae147ae1476p-7 0.009999999999999992
|
414
|
-
# # 0x1.47ae147ae1475p-7 0.00999999999999999
|
415
|
-
# # 0x1.47ae147ae1474p-7 0.009999999999999988
|
416
|
-
# # 0x1.47ae147ae1473p-7 0.009999999999999986
|
417
|
-
# # 0x1.47ae147ae1472p-7 0.009999999999999985
|
418
|
-
# # 0x1.47ae147ae1471p-7 0.009999999999999983
|
419
|
-
# # 0x1.47ae147ae147p-7 0.009999999999999981
|
420
|
-
# # 0x1.47ae147ae146fp-7 0.00999999999999998
|
421
|
-
# # 0x1.47ae147ae146ep-7 0.009999999999999978
|
422
|
-
# # 0x1.47ae147ae146dp-7 0.009999999999999976
|
423
|
-
# # 0x1.47ae147ae146cp-7 0.009999999999999974
|
424
|
-
# # 0x1.47ae147ae146bp-7 0.009999999999999972
|
425
|
-
# # 0x1.47ae147ae146ap-7 0.00999999999999997
|
426
|
-
# # 0x1.47ae147ae1469p-7 0.009999999999999969
|
427
|
-
# # 0x1.47ae147ae1468p-7 0.009999999999999967
|
428
|
-
#
|
429
|
-
def prev_float: () -> Float
|
430
|
-
|
431
|
-
# Returns `float / numeric`, same as Float#/.
|
432
|
-
#
|
433
|
-
def quo: (Complex) -> Complex
|
434
|
-
| (Numeric) -> Float
|
435
|
-
|
436
|
-
# Returns a simpler approximation of the value (flt-|eps| <= result <=
|
437
|
-
# flt+|eps|). If the optional argument `eps` is not given, it will be chosen
|
438
|
-
# automatically.
|
439
|
-
#
|
440
|
-
# 0.3.rationalize #=> (3/10)
|
441
|
-
# 1.333.rationalize #=> (1333/1000)
|
442
|
-
# 1.333.rationalize(0.01) #=> (4/3)
|
443
|
-
#
|
444
|
-
# See also Float#to_r.
|
445
|
-
#
|
446
|
-
def rationalize: (?Numeric eps) -> Rational
|
447
|
-
|
448
|
-
def real: () -> Float
|
449
|
-
|
450
|
-
def real?: () -> true
|
451
|
-
|
452
|
-
def rect: () -> [ Float, Numeric ]
|
453
|
-
|
454
|
-
alias rectangular rect
|
455
|
-
|
456
|
-
def remainder: (Numeric) -> Float
|
457
|
-
|
458
|
-
# Returns `float` rounded to the nearest value with a precision of `ndigits`
|
459
|
-
# decimal digits (default: 0).
|
460
|
-
#
|
461
|
-
# When the precision is negative, the returned value is an integer with at least
|
462
|
-
# `ndigits.abs` trailing zeros.
|
463
|
-
#
|
464
|
-
# Returns a floating point number when `ndigits` is positive, otherwise returns
|
465
|
-
# an integer.
|
466
|
-
#
|
467
|
-
# 1.4.round #=> 1
|
468
|
-
# 1.5.round #=> 2
|
469
|
-
# 1.6.round #=> 2
|
470
|
-
# (-1.5).round #=> -2
|
471
|
-
#
|
472
|
-
# 1.234567.round(2) #=> 1.23
|
473
|
-
# 1.234567.round(3) #=> 1.235
|
474
|
-
# 1.234567.round(4) #=> 1.2346
|
475
|
-
# 1.234567.round(5) #=> 1.23457
|
476
|
-
#
|
477
|
-
# 34567.89.round(-5) #=> 0
|
478
|
-
# 34567.89.round(-4) #=> 30000
|
479
|
-
# 34567.89.round(-3) #=> 35000
|
480
|
-
# 34567.89.round(-2) #=> 34600
|
481
|
-
# 34567.89.round(-1) #=> 34570
|
482
|
-
# 34567.89.round(0) #=> 34568
|
483
|
-
# 34567.89.round(1) #=> 34567.9
|
484
|
-
# 34567.89.round(2) #=> 34567.89
|
485
|
-
# 34567.89.round(3) #=> 34567.89
|
486
|
-
#
|
487
|
-
# If the optional `half` keyword argument is given, numbers that are half-way
|
488
|
-
# between two possible rounded values will be rounded according to the specified
|
489
|
-
# tie-breaking `mode`:
|
490
|
-
#
|
491
|
-
# * `:up` or `nil`: round half away from zero (default)
|
492
|
-
# * `:down`: round half toward zero
|
493
|
-
# * `:even`: round half toward the nearest even number
|
494
|
-
#
|
495
|
-
# 2.5.round(half: :up) #=> 3
|
496
|
-
# 2.5.round(half: :down) #=> 2
|
497
|
-
# 2.5.round(half: :even) #=> 2
|
498
|
-
# 3.5.round(half: :up) #=> 4
|
499
|
-
# 3.5.round(half: :down) #=> 3
|
500
|
-
# 3.5.round(half: :even) #=> 4
|
501
|
-
# (-2.5).round(half: :up) #=> -3
|
502
|
-
# (-2.5).round(half: :down) #=> -2
|
503
|
-
# (-2.5).round(half: :even) #=> -2
|
504
|
-
#
|
505
|
-
def round: (?half: :up | :down | :even) -> Integer
|
506
|
-
| (int digits, ?half: :up | :down | :even) -> (Integer | Float)
|
507
|
-
|
508
|
-
def step: (?Numeric limit, ?Numeric step) { (Float) -> void } -> self
|
509
|
-
| (?Numeric limit, ?Numeric step) -> Enumerator[Float, self]
|
510
|
-
| (?by: Numeric, ?to: Numeric) { (Float) -> void } -> self
|
511
|
-
| (?by: Numeric, ?to: Numeric) -> Enumerator[Float, self]
|
512
|
-
|
513
|
-
def to_c: () -> Complex
|
514
|
-
|
515
|
-
# Since `float` is already a Float, returns `self`.
|
516
|
-
#
|
517
|
-
def to_f: () -> Float
|
518
|
-
|
519
|
-
# Returns the `float` truncated to an Integer.
|
520
|
-
#
|
521
|
-
# 1.2.to_i #=> 1
|
522
|
-
# (-1.2).to_i #=> -1
|
523
|
-
#
|
524
|
-
# Note that the limited precision of floating point arithmetic might lead to
|
525
|
-
# surprising results:
|
526
|
-
#
|
527
|
-
# (0.3 / 0.1).to_i #=> 2 (!)
|
528
|
-
#
|
529
|
-
# #to_int is an alias for #to_i.
|
530
|
-
#
|
531
|
-
def to_i: () -> Integer
|
532
|
-
|
533
|
-
# Returns the `float` truncated to an Integer.
|
534
|
-
#
|
535
|
-
# 1.2.to_i #=> 1
|
536
|
-
# (-1.2).to_i #=> -1
|
537
|
-
#
|
538
|
-
# Note that the limited precision of floating point arithmetic might lead to
|
539
|
-
# surprising results:
|
540
|
-
#
|
541
|
-
# (0.3 / 0.1).to_i #=> 2 (!)
|
542
|
-
#
|
543
|
-
# #to_int is an alias for #to_i.
|
544
|
-
#
|
545
|
-
alias to_int to_i
|
546
|
-
|
547
|
-
# Returns the value as a rational.
|
548
|
-
#
|
549
|
-
# 2.0.to_r #=> (2/1)
|
550
|
-
# 2.5.to_r #=> (5/2)
|
551
|
-
# -0.75.to_r #=> (-3/4)
|
552
|
-
# 0.0.to_r #=> (0/1)
|
553
|
-
# 0.3.to_r #=> (5404319552844595/18014398509481984)
|
554
|
-
#
|
555
|
-
# NOTE: 0.3.to_r isn't the same as "0.3".to_r. The latter is equivalent to
|
556
|
-
# "3/10".to_r, but the former isn't so.
|
557
|
-
#
|
558
|
-
# 0.3.to_r == 3/10r #=> false
|
559
|
-
# "0.3".to_r == 3/10r #=> true
|
560
|
-
#
|
561
|
-
# See also Float#rationalize.
|
562
|
-
#
|
563
|
-
def to_r: () -> Rational
|
564
|
-
|
565
|
-
# Returns a string containing a representation of `self`. As well as a fixed or
|
566
|
-
# exponential form of the `float`, the call may return `NaN`, `Infinity`, and
|
567
|
-
# `-Infinity`.
|
568
|
-
#
|
569
|
-
def to_s: () -> String
|
570
|
-
|
571
|
-
# Returns `float` truncated (toward zero) to a precision of `ndigits` decimal
|
572
|
-
# digits (default: 0).
|
573
|
-
#
|
574
|
-
# When the precision is negative, the returned value is an integer with at least
|
575
|
-
# `ndigits.abs` trailing zeros.
|
576
|
-
#
|
577
|
-
# Returns a floating point number when `ndigits` is positive, otherwise returns
|
578
|
-
# an integer.
|
579
|
-
#
|
580
|
-
# 2.8.truncate #=> 2
|
581
|
-
# (-2.8).truncate #=> -2
|
582
|
-
# 1.234567.truncate(2) #=> 1.23
|
583
|
-
# 34567.89.truncate(-2) #=> 34500
|
584
|
-
#
|
585
|
-
# Note that the limited precision of floating point arithmetic might lead to
|
586
|
-
# surprising results:
|
587
|
-
#
|
588
|
-
# (0.3 / 0.1).truncate #=> 2 (!)
|
589
|
-
#
|
590
|
-
def truncate: () -> Integer
|
591
|
-
| (Integer ndigits) -> (Integer | Float)
|
592
|
-
|
593
|
-
# Returns `true` if `float` is 0.0.
|
594
|
-
#
|
595
|
-
def zero?: () -> bool
|
596
|
-
end
|
597
|
-
|
598
|
-
# The minimum number of significant decimal digits in a double-precision
|
599
|
-
# floating point.
|
600
|
-
#
|
601
|
-
# Usually defaults to 15.
|
602
|
-
#
|
603
|
-
Float::DIG: Integer
|
604
|
-
|
605
|
-
# The difference between 1 and the smallest double-precision floating point
|
606
|
-
# number greater than 1.
|
607
|
-
#
|
608
|
-
# Usually defaults to 2.2204460492503131e-16.
|
609
|
-
#
|
610
|
-
Float::EPSILON: Float
|
611
|
-
|
612
|
-
# An expression representing positive infinity.
|
613
|
-
#
|
614
|
-
Float::INFINITY: Float
|
615
|
-
|
616
|
-
# The number of base digits for the `double` data type.
|
617
|
-
#
|
618
|
-
# Usually defaults to 53.
|
619
|
-
#
|
620
|
-
Float::MANT_DIG: Integer
|
621
|
-
|
622
|
-
# The largest possible integer in a double-precision floating point number.
|
623
|
-
#
|
624
|
-
# Usually defaults to 1.7976931348623157e+308.
|
625
|
-
#
|
626
|
-
Float::MAX: Float
|
627
|
-
|
628
|
-
# The largest positive exponent in a double-precision floating point where 10
|
629
|
-
# raised to this power minus 1.
|
630
|
-
#
|
631
|
-
# Usually defaults to 308.
|
632
|
-
#
|
633
|
-
Float::MAX_10_EXP: Integer
|
634
|
-
|
635
|
-
# The largest possible exponent value in a double-precision floating point.
|
636
|
-
#
|
637
|
-
# Usually defaults to 1024.
|
638
|
-
#
|
639
|
-
Float::MAX_EXP: Integer
|
640
|
-
|
641
|
-
# The smallest positive normalized number in a double-precision floating point.
|
642
|
-
#
|
643
|
-
# Usually defaults to 2.2250738585072014e-308.
|
644
|
-
#
|
645
|
-
# If the platform supports denormalized numbers, there are numbers between zero
|
646
|
-
# and Float::MIN. 0.0.next_float returns the smallest positive floating point
|
647
|
-
# number including denormalized numbers.
|
648
|
-
#
|
649
|
-
Float::MIN: Float
|
650
|
-
|
651
|
-
# The smallest negative exponent in a double-precision floating point where 10
|
652
|
-
# raised to this power minus 1.
|
653
|
-
#
|
654
|
-
# Usually defaults to -307.
|
655
|
-
#
|
656
|
-
Float::MIN_10_EXP: Integer
|
657
|
-
|
658
|
-
# The smallest possible exponent value in a double-precision floating point.
|
659
|
-
#
|
660
|
-
# Usually defaults to -1021.
|
661
|
-
#
|
662
|
-
Float::MIN_EXP: Integer
|
663
|
-
|
664
|
-
# An expression representing a value which is "not a number".
|
665
|
-
#
|
666
|
-
Float::NAN: Float
|
667
|
-
|
668
|
-
# The base of the floating point, or number of unique digits used to represent
|
669
|
-
# the number.
|
670
|
-
#
|
671
|
-
# Usually defaults to 2 on most systems, which would represent a base-10
|
672
|
-
# decimal.
|
673
|
-
#
|
674
|
-
Float::RADIX: Integer
|
675
|
-
|
676
|
-
# Deprecated, do not use.
|
677
|
-
#
|
678
|
-
# Represents the rounding mode for floating point addition at the start time.
|
679
|
-
#
|
680
|
-
# Usually defaults to 1, rounding to the nearest number.
|
681
|
-
#
|
682
|
-
# Other modes include:
|
683
|
-
#
|
684
|
-
# -1
|
685
|
-
# : Indeterminable
|
686
|
-
# 0
|
687
|
-
# : Rounding towards zero
|
688
|
-
# 1
|
689
|
-
# : Rounding to the nearest number
|
690
|
-
# 2
|
691
|
-
# : Rounding towards positive infinity
|
692
|
-
# 3
|
693
|
-
# : Rounding towards negative infinity
|
694
|
-
#
|
695
|
-
#
|
696
|
-
Float::ROUNDS: Integer
|