rbs-relaxed 3.9.0.1
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.
- checksums.yaml +7 -0
- data/.github/dependabot.yml +22 -0
- data/.github/workflows/comments.yml +35 -0
- data/.github/workflows/dependabot.yml +30 -0
- data/.github/workflows/ruby.yml +82 -0
- data/.github/workflows/typecheck.yml +38 -0
- data/.github/workflows/windows.yml +43 -0
- data/.gitignore +23 -0
- data/.rubocop.yml +68 -0
- data/BSDL +22 -0
- data/CHANGELOG.md +1868 -0
- data/COPYING +56 -0
- data/README.md +203 -0
- data/Rakefile +417 -0
- data/Steepfile +44 -0
- data/config.yml +313 -0
- data/core/array.rbs +4062 -0
- data/core/basic_object.rbs +375 -0
- data/core/binding.rbs +150 -0
- data/core/builtin.rbs +277 -0
- data/core/class.rbs +220 -0
- data/core/comparable.rbs +171 -0
- data/core/complex.rbs +786 -0
- data/core/constants.rbs +96 -0
- data/core/data.rbs +415 -0
- data/core/dir.rbs +981 -0
- data/core/encoding.rbs +1371 -0
- data/core/enumerable.rbs +2405 -0
- data/core/enumerator/product.rbs +92 -0
- data/core/enumerator.rbs +630 -0
- data/core/env.rbs +6 -0
- data/core/errno.rbs +673 -0
- data/core/errors.rbs +760 -0
- data/core/exception.rbs +485 -0
- data/core/false_class.rbs +82 -0
- data/core/fiber.rbs +550 -0
- data/core/fiber_error.rbs +11 -0
- data/core/file.rbs +2936 -0
- data/core/file_test.rbs +331 -0
- data/core/float.rbs +1151 -0
- data/core/gc.rbs +644 -0
- data/core/global_variables.rbs +184 -0
- data/core/hash.rbs +1861 -0
- data/core/integer.rbs +1413 -0
- data/core/io/buffer.rbs +984 -0
- data/core/io/wait.rbs +70 -0
- data/core/io.rbs +3406 -0
- data/core/kernel.rbs +3096 -0
- data/core/marshal.rbs +207 -0
- data/core/match_data.rbs +635 -0
- data/core/math.rbs +729 -0
- data/core/method.rbs +386 -0
- data/core/module.rbs +1704 -0
- data/core/nil_class.rbs +209 -0
- data/core/numeric.rbs +818 -0
- data/core/object.rbs +110 -0
- data/core/object_space/weak_key_map.rbs +166 -0
- data/core/object_space.rbs +190 -0
- data/core/proc.rbs +868 -0
- data/core/process.rbs +2296 -0
- data/core/ractor.rbs +1068 -0
- data/core/random.rbs +237 -0
- data/core/range.rbs +1107 -0
- data/core/rational.rbs +531 -0
- data/core/rb_config.rbs +88 -0
- data/core/rbs/unnamed/argf.rbs +1229 -0
- data/core/rbs/unnamed/env_class.rbs +1209 -0
- data/core/rbs/unnamed/random.rbs +293 -0
- data/core/refinement.rbs +59 -0
- data/core/regexp.rbs +1930 -0
- data/core/ruby_vm.rbs +765 -0
- data/core/rubygems/basic_specification.rbs +6 -0
- data/core/rubygems/config_file.rbs +38 -0
- data/core/rubygems/dependency_installer.rbs +6 -0
- data/core/rubygems/errors.rbs +176 -0
- data/core/rubygems/installer.rbs +15 -0
- data/core/rubygems/path_support.rbs +6 -0
- data/core/rubygems/platform.rbs +7 -0
- data/core/rubygems/request_set.rbs +49 -0
- data/core/rubygems/requirement.rbs +148 -0
- data/core/rubygems/rubygems.rbs +1171 -0
- data/core/rubygems/source_list.rbs +15 -0
- data/core/rubygems/specification.rbs +23 -0
- data/core/rubygems/stream_ui.rbs +5 -0
- data/core/rubygems/uninstaller.rbs +10 -0
- data/core/rubygems/version.rbs +294 -0
- data/core/set.rbs +621 -0
- data/core/signal.rbs +100 -0
- data/core/string.rbs +3583 -0
- data/core/struct.rbs +667 -0
- data/core/symbol.rbs +475 -0
- data/core/thread.rbs +1765 -0
- data/core/thread_group.rbs +79 -0
- data/core/time.rbs +1762 -0
- data/core/trace_point.rbs +477 -0
- data/core/true_class.rbs +98 -0
- data/core/unbound_method.rbs +329 -0
- data/core/warning.rbs +87 -0
- data/docs/CONTRIBUTING.md +106 -0
- data/docs/architecture.md +110 -0
- data/docs/collection.md +192 -0
- data/docs/data_and_struct.md +86 -0
- data/docs/gem.md +57 -0
- data/docs/rbs_by_example.md +309 -0
- data/docs/repo.md +125 -0
- data/docs/sigs.md +167 -0
- data/docs/stdlib.md +147 -0
- data/docs/syntax.md +910 -0
- data/docs/tools.md +17 -0
- data/exe/rbs +7 -0
- data/ext/rbs_extension/extconf.rb +15 -0
- data/ext/rbs_extension/lexer.c +2728 -0
- data/ext/rbs_extension/lexer.h +179 -0
- data/ext/rbs_extension/lexer.re +147 -0
- data/ext/rbs_extension/lexstate.c +175 -0
- data/ext/rbs_extension/location.c +325 -0
- data/ext/rbs_extension/location.h +85 -0
- data/ext/rbs_extension/main.c +33 -0
- data/ext/rbs_extension/parser.c +2973 -0
- data/ext/rbs_extension/parser.h +18 -0
- data/ext/rbs_extension/parserstate.c +397 -0
- data/ext/rbs_extension/parserstate.h +163 -0
- data/ext/rbs_extension/rbs_extension.h +31 -0
- data/ext/rbs_extension/unescape.c +32 -0
- data/goodcheck.yml +91 -0
- data/include/rbs/constants.h +82 -0
- data/include/rbs/ruby_objs.h +72 -0
- data/include/rbs/util/rbs_constant_pool.h +219 -0
- data/include/rbs.h +7 -0
- data/lib/rbs/ancestor_graph.rb +92 -0
- data/lib/rbs/annotate/annotations.rb +199 -0
- data/lib/rbs/annotate/formatter.rb +92 -0
- data/lib/rbs/annotate/rdoc_annotator.rb +400 -0
- data/lib/rbs/annotate/rdoc_source.rb +131 -0
- data/lib/rbs/annotate.rb +8 -0
- data/lib/rbs/ast/annotation.rb +29 -0
- data/lib/rbs/ast/comment.rb +29 -0
- data/lib/rbs/ast/declarations.rb +467 -0
- data/lib/rbs/ast/directives.rb +49 -0
- data/lib/rbs/ast/members.rb +451 -0
- data/lib/rbs/ast/type_param.rb +225 -0
- data/lib/rbs/ast/visitor.rb +137 -0
- data/lib/rbs/buffer.rb +67 -0
- data/lib/rbs/builtin_names.rb +58 -0
- data/lib/rbs/cli/colored_io.rb +48 -0
- data/lib/rbs/cli/diff.rb +83 -0
- data/lib/rbs/cli/validate.rb +357 -0
- data/lib/rbs/cli.rb +1223 -0
- data/lib/rbs/collection/cleaner.rb +38 -0
- data/lib/rbs/collection/config/lockfile.rb +92 -0
- data/lib/rbs/collection/config/lockfile_generator.rb +218 -0
- data/lib/rbs/collection/config.rb +81 -0
- data/lib/rbs/collection/installer.rb +32 -0
- data/lib/rbs/collection/sources/base.rb +14 -0
- data/lib/rbs/collection/sources/git.rb +258 -0
- data/lib/rbs/collection/sources/local.rb +81 -0
- data/lib/rbs/collection/sources/rubygems.rb +48 -0
- data/lib/rbs/collection/sources/stdlib.rb +50 -0
- data/lib/rbs/collection/sources.rb +38 -0
- data/lib/rbs/collection.rb +16 -0
- data/lib/rbs/constant.rb +28 -0
- data/lib/rbs/definition.rb +401 -0
- data/lib/rbs/definition_builder/ancestor_builder.rb +620 -0
- data/lib/rbs/definition_builder/method_builder.rb +254 -0
- data/lib/rbs/definition_builder.rb +845 -0
- data/lib/rbs/diff.rb +125 -0
- data/lib/rbs/environment/use_map.rb +77 -0
- data/lib/rbs/environment.rb +829 -0
- data/lib/rbs/environment_loader.rb +173 -0
- data/lib/rbs/environment_walker.rb +155 -0
- data/lib/rbs/errors.rb +645 -0
- data/lib/rbs/factory.rb +18 -0
- data/lib/rbs/file_finder.rb +28 -0
- data/lib/rbs/location_aux.rb +138 -0
- data/lib/rbs/locator.rb +243 -0
- data/lib/rbs/method_type.rb +143 -0
- data/lib/rbs/namespace.rb +125 -0
- data/lib/rbs/parser/lex_result.rb +15 -0
- data/lib/rbs/parser/token.rb +23 -0
- data/lib/rbs/parser_aux.rb +114 -0
- data/lib/rbs/prototype/helpers.rb +140 -0
- data/lib/rbs/prototype/node_usage.rb +99 -0
- data/lib/rbs/prototype/rb.rb +840 -0
- data/lib/rbs/prototype/rbi.rb +641 -0
- data/lib/rbs/prototype/runtime/helpers.rb +59 -0
- data/lib/rbs/prototype/runtime/reflection.rb +19 -0
- data/lib/rbs/prototype/runtime/value_object_generator.rb +279 -0
- data/lib/rbs/prototype/runtime.rb +667 -0
- data/lib/rbs/repository.rb +127 -0
- data/lib/rbs/resolver/constant_resolver.rb +219 -0
- data/lib/rbs/resolver/type_name_resolver.rb +91 -0
- data/lib/rbs/sorter.rb +198 -0
- data/lib/rbs/substitution.rb +83 -0
- data/lib/rbs/subtractor.rb +201 -0
- data/lib/rbs/test/errors.rb +80 -0
- data/lib/rbs/test/guaranteed.rb +30 -0
- data/lib/rbs/test/hook.rb +212 -0
- data/lib/rbs/test/observer.rb +19 -0
- data/lib/rbs/test/setup.rb +84 -0
- data/lib/rbs/test/setup_helper.rb +50 -0
- data/lib/rbs/test/tester.rb +167 -0
- data/lib/rbs/test/type_check.rb +435 -0
- data/lib/rbs/test.rb +112 -0
- data/lib/rbs/type_alias_dependency.rb +100 -0
- data/lib/rbs/type_alias_regularity.rb +126 -0
- data/lib/rbs/type_name.rb +109 -0
- data/lib/rbs/types.rb +1596 -0
- data/lib/rbs/unit_test/convertibles.rb +176 -0
- data/lib/rbs/unit_test/spy.rb +138 -0
- data/lib/rbs/unit_test/type_assertions.rb +347 -0
- data/lib/rbs/unit_test/with_aliases.rb +143 -0
- data/lib/rbs/unit_test.rb +6 -0
- data/lib/rbs/validator.rb +186 -0
- data/lib/rbs/variance_calculator.rb +189 -0
- data/lib/rbs/vendorer.rb +71 -0
- data/lib/rbs/version.rb +5 -0
- data/lib/rbs/writer.rb +424 -0
- data/lib/rbs.rb +94 -0
- data/lib/rdoc/discover.rb +20 -0
- data/lib/rdoc_plugin/parser.rb +163 -0
- data/rbs-relaxed.gemspec +48 -0
- data/schema/annotation.json +14 -0
- data/schema/comment.json +26 -0
- data/schema/decls.json +326 -0
- data/schema/function.json +87 -0
- data/schema/location.json +56 -0
- data/schema/members.json +266 -0
- data/schema/methodType.json +50 -0
- data/schema/typeParam.json +36 -0
- data/schema/types.json +317 -0
- data/sig/ancestor_builder.rbs +163 -0
- data/sig/ancestor_graph.rbs +60 -0
- data/sig/annotate/annotations.rbs +102 -0
- data/sig/annotate/formatter.rbs +24 -0
- data/sig/annotate/rdoc_annotater.rbs +82 -0
- data/sig/annotate/rdoc_source.rbs +30 -0
- data/sig/annotation.rbs +27 -0
- data/sig/buffer.rbs +32 -0
- data/sig/builtin_names.rbs +44 -0
- data/sig/cli/colored_io.rbs +15 -0
- data/sig/cli/diff.rbs +21 -0
- data/sig/cli/validate.rbs +43 -0
- data/sig/cli.rbs +87 -0
- data/sig/collection/cleaner.rbs +13 -0
- data/sig/collection/config/lockfile.rbs +74 -0
- data/sig/collection/config/lockfile_generator.rbs +66 -0
- data/sig/collection/config.rbs +46 -0
- data/sig/collection/installer.rbs +17 -0
- data/sig/collection/sources.rbs +214 -0
- data/sig/collection.rbs +4 -0
- data/sig/comment.rbs +26 -0
- data/sig/constant.rbs +21 -0
- data/sig/declarations.rbs +267 -0
- data/sig/definition.rbs +173 -0
- data/sig/definition_builder.rbs +165 -0
- data/sig/diff.rbs +28 -0
- data/sig/directives.rbs +77 -0
- data/sig/environment.rbs +279 -0
- data/sig/environment_loader.rbs +111 -0
- data/sig/environment_walker.rbs +65 -0
- data/sig/errors.rbs +405 -0
- data/sig/factory.rbs +5 -0
- data/sig/file_finder.rbs +28 -0
- data/sig/location.rbs +110 -0
- data/sig/locator.rbs +58 -0
- data/sig/manifest.yaml +7 -0
- data/sig/members.rbs +258 -0
- data/sig/method_builder.rbs +84 -0
- data/sig/method_types.rbs +58 -0
- data/sig/namespace.rbs +146 -0
- data/sig/parser.rbs +100 -0
- data/sig/prototype/helpers.rbs +27 -0
- data/sig/prototype/node_usage.rbs +20 -0
- data/sig/prototype/rb.rbs +96 -0
- data/sig/prototype/rbi.rbs +75 -0
- data/sig/prototype/runtime.rbs +182 -0
- data/sig/rbs.rbs +21 -0
- data/sig/rdoc/rbs.rbs +67 -0
- data/sig/repository.rbs +85 -0
- data/sig/resolver/constant_resolver.rbs +92 -0
- data/sig/resolver/context.rbs +34 -0
- data/sig/resolver/type_name_resolver.rbs +35 -0
- data/sig/shims/bundler.rbs +38 -0
- data/sig/shims/enumerable.rbs +5 -0
- data/sig/shims/rubygems.rbs +19 -0
- data/sig/sorter.rbs +41 -0
- data/sig/substitution.rbs +48 -0
- data/sig/subtractor.rbs +37 -0
- data/sig/test/errors.rbs +52 -0
- data/sig/test/guranteed.rbs +9 -0
- data/sig/test/type_check.rbs +19 -0
- data/sig/test.rbs +82 -0
- data/sig/type_alias_dependency.rbs +53 -0
- data/sig/type_alias_regularity.rbs +98 -0
- data/sig/type_param.rbs +110 -0
- data/sig/typename.rbs +79 -0
- data/sig/types.rbs +579 -0
- data/sig/unit_test/convertibles.rbs +154 -0
- data/sig/unit_test/spy.rbs +30 -0
- data/sig/unit_test/type_assertions.rbs +196 -0
- data/sig/unit_test/with_aliases.rbs +136 -0
- data/sig/use_map.rbs +35 -0
- data/sig/util.rbs +9 -0
- data/sig/validator.rbs +63 -0
- data/sig/variance_calculator.rbs +87 -0
- data/sig/vendorer.rbs +51 -0
- data/sig/version.rbs +3 -0
- data/sig/visitor.rbs +47 -0
- data/sig/writer.rbs +127 -0
- data/src/constants.c +153 -0
- data/src/ruby_objs.c +795 -0
- data/src/util/rbs_constant_pool.c +342 -0
- data/stdlib/abbrev/0/abbrev.rbs +66 -0
- data/stdlib/abbrev/0/array.rbs +26 -0
- data/stdlib/base64/0/base64.rbs +355 -0
- data/stdlib/benchmark/0/benchmark.rbs +452 -0
- data/stdlib/bigdecimal/0/big_decimal.rbs +1629 -0
- data/stdlib/bigdecimal-math/0/big_math.rbs +119 -0
- data/stdlib/bigdecimal-math/0/manifest.yaml +2 -0
- data/stdlib/cgi/0/core.rbs +1285 -0
- data/stdlib/cgi/0/manifest.yaml +3 -0
- data/stdlib/coverage/0/coverage.rbs +263 -0
- data/stdlib/csv/0/csv.rbs +3776 -0
- data/stdlib/csv/0/manifest.yaml +3 -0
- data/stdlib/date/0/date.rbs +1585 -0
- data/stdlib/date/0/date_time.rbs +616 -0
- data/stdlib/date/0/time.rbs +26 -0
- data/stdlib/dbm/0/dbm.rbs +421 -0
- data/stdlib/delegate/0/delegator.rbs +184 -0
- data/stdlib/delegate/0/kernel.rbs +47 -0
- data/stdlib/delegate/0/simple_delegator.rbs +96 -0
- data/stdlib/did_you_mean/0/did_you_mean.rbs +343 -0
- data/stdlib/digest/0/digest.rbs +577 -0
- data/stdlib/erb/0/erb.rbs +532 -0
- data/stdlib/etc/0/etc.rbs +865 -0
- data/stdlib/fileutils/0/fileutils.rbs +1734 -0
- data/stdlib/find/0/find.rbs +49 -0
- data/stdlib/forwardable/0/forwardable.rbs +268 -0
- data/stdlib/io-console/0/io-console.rbs +414 -0
- data/stdlib/ipaddr/0/ipaddr.rbs +428 -0
- data/stdlib/json/0/json.rbs +1916 -0
- data/stdlib/kconv/0/kconv.rbs +166 -0
- data/stdlib/logger/0/formatter.rbs +45 -0
- data/stdlib/logger/0/log_device.rbs +100 -0
- data/stdlib/logger/0/logger.rbs +796 -0
- data/stdlib/logger/0/manifest.yaml +2 -0
- data/stdlib/logger/0/period.rbs +17 -0
- data/stdlib/logger/0/severity.rbs +34 -0
- data/stdlib/minitest/0/kernel.rbs +42 -0
- data/stdlib/minitest/0/minitest/abstract_reporter.rbs +52 -0
- data/stdlib/minitest/0/minitest/assertion.rbs +17 -0
- data/stdlib/minitest/0/minitest/assertions.rbs +590 -0
- data/stdlib/minitest/0/minitest/backtrace_filter.rbs +23 -0
- data/stdlib/minitest/0/minitest/bench_spec.rbs +102 -0
- data/stdlib/minitest/0/minitest/benchmark.rbs +259 -0
- data/stdlib/minitest/0/minitest/composite_reporter.rbs +25 -0
- data/stdlib/minitest/0/minitest/compress.rbs +13 -0
- data/stdlib/minitest/0/minitest/error_on_warning.rbs +3 -0
- data/stdlib/minitest/0/minitest/expectation.rbs +2 -0
- data/stdlib/minitest/0/minitest/expectations.rbs +21 -0
- data/stdlib/minitest/0/minitest/guard.rbs +64 -0
- data/stdlib/minitest/0/minitest/mock.rbs +64 -0
- data/stdlib/minitest/0/minitest/parallel/executor.rbs +46 -0
- data/stdlib/minitest/0/minitest/parallel/test/class_methods.rbs +5 -0
- data/stdlib/minitest/0/minitest/parallel/test.rbs +3 -0
- data/stdlib/minitest/0/minitest/parallel.rbs +2 -0
- data/stdlib/minitest/0/minitest/pride_io.rbs +62 -0
- data/stdlib/minitest/0/minitest/pride_lol.rbs +19 -0
- data/stdlib/minitest/0/minitest/progress_reporter.rbs +11 -0
- data/stdlib/minitest/0/minitest/reportable.rbs +53 -0
- data/stdlib/minitest/0/minitest/reporter.rbs +5 -0
- data/stdlib/minitest/0/minitest/result.rbs +28 -0
- data/stdlib/minitest/0/minitest/runnable.rbs +163 -0
- data/stdlib/minitest/0/minitest/skip.rbs +6 -0
- data/stdlib/minitest/0/minitest/spec/dsl/instance_methods.rbs +48 -0
- data/stdlib/minitest/0/minitest/spec/dsl.rbs +129 -0
- data/stdlib/minitest/0/minitest/spec.rbs +11 -0
- data/stdlib/minitest/0/minitest/statistics_reporter.rbs +81 -0
- data/stdlib/minitest/0/minitest/summary_reporter.rbs +18 -0
- data/stdlib/minitest/0/minitest/test/lifecycle_hooks.rbs +92 -0
- data/stdlib/minitest/0/minitest/test.rbs +69 -0
- data/stdlib/minitest/0/minitest/unexpected_error.rbs +12 -0
- data/stdlib/minitest/0/minitest/unexpected_warning.rbs +6 -0
- data/stdlib/minitest/0/minitest/unit/test_case.rbs +3 -0
- data/stdlib/minitest/0/minitest/unit.rbs +4 -0
- data/stdlib/minitest/0/minitest.rbs +115 -0
- data/stdlib/monitor/0/monitor.rbs +363 -0
- data/stdlib/mutex_m/0/mutex_m.rbs +104 -0
- data/stdlib/net-http/0/manifest.yaml +3 -0
- data/stdlib/net-http/0/net-http.rbs +5552 -0
- data/stdlib/net-protocol/0/manifest.yaml +2 -0
- data/stdlib/net-protocol/0/net-protocol.rbs +56 -0
- data/stdlib/net-smtp/0/manifest.yaml +2 -0
- data/stdlib/net-smtp/0/net-smtp.rbs +55 -0
- data/stdlib/nkf/0/nkf.rbs +402 -0
- data/stdlib/objspace/0/objspace.rbs +487 -0
- data/stdlib/observable/0/observable.rbs +217 -0
- data/stdlib/open-uri/0/manifest.yaml +4 -0
- data/stdlib/open-uri/0/open-uri.rbs +393 -0
- data/stdlib/open3/0/open3.rbs +147 -0
- data/stdlib/openssl/0/manifest.yaml +3 -0
- data/stdlib/openssl/0/openssl.rbs +12113 -0
- data/stdlib/optparse/0/optparse.rbs +1725 -0
- data/stdlib/pathname/0/pathname.rbs +1406 -0
- data/stdlib/pp/0/manifest.yaml +2 -0
- data/stdlib/pp/0/pp.rbs +300 -0
- data/stdlib/prettyprint/0/prettyprint.rbs +383 -0
- data/stdlib/pstore/0/pstore.rbs +603 -0
- data/stdlib/psych/0/core_ext.rbs +12 -0
- data/stdlib/psych/0/dbm.rbs +237 -0
- data/stdlib/psych/0/manifest.yaml +3 -0
- data/stdlib/psych/0/psych.rbs +402 -0
- data/stdlib/psych/0/store.rbs +59 -0
- data/stdlib/pty/0/pty.rbs +237 -0
- data/stdlib/rdoc/0/code_object.rbs +51 -0
- data/stdlib/rdoc/0/comment.rbs +59 -0
- data/stdlib/rdoc/0/context.rbs +153 -0
- data/stdlib/rdoc/0/markup.rbs +117 -0
- data/stdlib/rdoc/0/parser.rbs +56 -0
- data/stdlib/rdoc/0/rdoc.rbs +391 -0
- data/stdlib/rdoc/0/ri.rbs +17 -0
- data/stdlib/rdoc/0/store.rbs +48 -0
- data/stdlib/rdoc/0/top_level.rbs +97 -0
- data/stdlib/resolv/0/manifest.yaml +3 -0
- data/stdlib/resolv/0/resolv.rbs +1830 -0
- data/stdlib/ripper/0/ripper.rbs +1648 -0
- data/stdlib/securerandom/0/securerandom.rbs +62 -0
- data/stdlib/shellwords/0/shellwords.rbs +229 -0
- data/stdlib/singleton/0/singleton.rbs +131 -0
- data/stdlib/socket/0/addrinfo.rbs +666 -0
- data/stdlib/socket/0/basic_socket.rbs +590 -0
- data/stdlib/socket/0/constants.rbs +2295 -0
- data/stdlib/socket/0/ip_socket.rbs +92 -0
- data/stdlib/socket/0/socket.rbs +4157 -0
- data/stdlib/socket/0/socket_error.rbs +5 -0
- data/stdlib/socket/0/tcp_server.rbs +192 -0
- data/stdlib/socket/0/tcp_socket.rbs +79 -0
- data/stdlib/socket/0/udp_socket.rbs +133 -0
- data/stdlib/socket/0/unix_server.rbs +169 -0
- data/stdlib/socket/0/unix_socket.rbs +172 -0
- data/stdlib/stringio/0/stringio.rbs +567 -0
- data/stdlib/strscan/0/string_scanner.rbs +1627 -0
- data/stdlib/tempfile/0/tempfile.rbs +479 -0
- data/stdlib/time/0/time.rbs +432 -0
- data/stdlib/timeout/0/timeout.rbs +81 -0
- data/stdlib/tmpdir/0/tmpdir.rbs +69 -0
- data/stdlib/tsort/0/cyclic.rbs +5 -0
- data/stdlib/tsort/0/interfaces.rbs +20 -0
- data/stdlib/tsort/0/tsort.rbs +409 -0
- data/stdlib/uri/0/common.rbs +582 -0
- data/stdlib/uri/0/file.rbs +118 -0
- data/stdlib/uri/0/ftp.rbs +13 -0
- data/stdlib/uri/0/generic.rbs +1108 -0
- data/stdlib/uri/0/http.rbs +104 -0
- data/stdlib/uri/0/https.rbs +14 -0
- data/stdlib/uri/0/ldap.rbs +230 -0
- data/stdlib/uri/0/ldaps.rbs +14 -0
- data/stdlib/uri/0/mailto.rbs +92 -0
- data/stdlib/uri/0/rfc2396_parser.rbs +189 -0
- data/stdlib/uri/0/rfc3986_parser.rbs +2 -0
- data/stdlib/uri/0/ws.rbs +13 -0
- data/stdlib/uri/0/wss.rbs +9 -0
- data/stdlib/yaml/0/manifest.yaml +2 -0
- data/stdlib/yaml/0/yaml.rbs +1 -0
- data/stdlib/zlib/0/buf_error.rbs +10 -0
- data/stdlib/zlib/0/data_error.rbs +10 -0
- data/stdlib/zlib/0/deflate.rbs +210 -0
- data/stdlib/zlib/0/error.rbs +20 -0
- data/stdlib/zlib/0/gzip_file/crc_error.rbs +12 -0
- data/stdlib/zlib/0/gzip_file/error.rbs +23 -0
- data/stdlib/zlib/0/gzip_file/length_error.rbs +12 -0
- data/stdlib/zlib/0/gzip_file/no_footer.rbs +11 -0
- data/stdlib/zlib/0/gzip_file.rbs +156 -0
- data/stdlib/zlib/0/gzip_reader.rbs +293 -0
- data/stdlib/zlib/0/gzip_writer.rbs +166 -0
- data/stdlib/zlib/0/inflate.rbs +180 -0
- data/stdlib/zlib/0/mem_error.rbs +10 -0
- data/stdlib/zlib/0/need_dict.rbs +13 -0
- data/stdlib/zlib/0/stream_end.rbs +11 -0
- data/stdlib/zlib/0/stream_error.rbs +11 -0
- data/stdlib/zlib/0/version_error.rbs +11 -0
- data/stdlib/zlib/0/zlib.rbs +449 -0
- data/stdlib/zlib/0/zstream.rbs +200 -0
- metadata +532 -0
data/core/float.rbs
ADDED
@@ -0,0 +1,1151 @@
|
|
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.
|
4
|
+
#
|
5
|
+
# Floating point has a different arithmetic and is an inexact number. So you
|
6
|
+
# should know its esoteric system. See following:
|
7
|
+
#
|
8
|
+
# * https://docs.oracle.com/cd/E19957-01/806-3568/ncg_goldberg.html
|
9
|
+
# * https://github.com/rdp/ruby_tutorials_core/wiki/Ruby-Talk-FAQ#-why-are-rub
|
10
|
+
# ys-floats-imprecise
|
11
|
+
# * https://en.wikipedia.org/wiki/Floating_point#Accuracy_problems
|
12
|
+
#
|
13
|
+
# You can create a Float object explicitly with:
|
14
|
+
#
|
15
|
+
# * A [floating-point literal](rdoc-ref:syntax/literals.rdoc@Float+Literals).
|
16
|
+
#
|
17
|
+
# You can convert certain objects to Floats with:
|
18
|
+
#
|
19
|
+
# * Method #Float.
|
20
|
+
#
|
21
|
+
# ## What's Here
|
22
|
+
#
|
23
|
+
# First, what's elsewhere. Class Float:
|
24
|
+
#
|
25
|
+
# * Inherits from [class Numeric](rdoc-ref:Numeric@What-27s+Here) and [class
|
26
|
+
# Object](rdoc-ref:Object@What-27s+Here).
|
27
|
+
# * Includes [module Comparable](rdoc-ref:Comparable@What-27s+Here).
|
28
|
+
#
|
29
|
+
# Here, class Float provides methods for:
|
30
|
+
#
|
31
|
+
# * [Querying](rdoc-ref:Float@Querying)
|
32
|
+
# * [Comparing](rdoc-ref:Float@Comparing)
|
33
|
+
# * [Converting](rdoc-ref:Float@Converting)
|
34
|
+
#
|
35
|
+
# ### Querying
|
36
|
+
#
|
37
|
+
# * #finite?: Returns whether `self` is finite.
|
38
|
+
# * #hash: Returns the integer hash code for `self`.
|
39
|
+
# * #infinite?: Returns whether `self` is infinite.
|
40
|
+
# * #nan?: Returns whether `self` is a NaN (not-a-number).
|
41
|
+
#
|
42
|
+
# ### Comparing
|
43
|
+
#
|
44
|
+
# * #<: Returns whether `self` is less than the given value.
|
45
|
+
# * #<=: Returns whether `self` is less than or equal to the given value.
|
46
|
+
# * #<=>: Returns a number indicating whether `self` is less than, equal to,
|
47
|
+
# or greater than the given value.
|
48
|
+
# * #== (aliased as #=== and #eql?): Returns whether `self` is equal to the
|
49
|
+
# given value.
|
50
|
+
# * #>: Returns whether `self` is greater than the given value.
|
51
|
+
# * #>=: Returns whether `self` is greater than or equal to the given value.
|
52
|
+
#
|
53
|
+
# ### Converting
|
54
|
+
#
|
55
|
+
# * #% (aliased as #modulo): Returns `self` modulo the given value.
|
56
|
+
# * #*: Returns the product of `self` and the given value.
|
57
|
+
# * #**: Returns the value of `self` raised to the power of the given value.
|
58
|
+
# * #+: Returns the sum of `self` and the given value.
|
59
|
+
# * #-: Returns the difference of `self` and the given value.
|
60
|
+
# * #/: Returns the quotient of `self` and the given value.
|
61
|
+
# * #ceil: Returns the smallest number greater than or equal to `self`.
|
62
|
+
# * #coerce: Returns a 2-element array containing the given value converted to
|
63
|
+
# a Float and `self`
|
64
|
+
# * #divmod: Returns a 2-element array containing the quotient and remainder
|
65
|
+
# results of dividing `self` by the given value.
|
66
|
+
# * #fdiv: Returns the Float result of dividing `self` by the given value.
|
67
|
+
# * #floor: Returns the greatest number smaller than or equal to `self`.
|
68
|
+
# * #next_float: Returns the next-larger representable Float.
|
69
|
+
# * #prev_float: Returns the next-smaller representable Float.
|
70
|
+
# * #quo: Returns the quotient from dividing `self` by the given value.
|
71
|
+
# * #round: Returns `self` rounded to the nearest value, to a given precision.
|
72
|
+
# * #to_i (aliased as #to_int): Returns `self` truncated to an Integer.
|
73
|
+
# * #to_s (aliased as #inspect): Returns a string containing the place-value
|
74
|
+
# representation of `self` in the given radix.
|
75
|
+
# * #truncate: Returns `self` truncated to a given precision.
|
76
|
+
#
|
77
|
+
class Float < Numeric
|
78
|
+
# <!--
|
79
|
+
# rdoc-file=numeric.c
|
80
|
+
# - self % other -> float
|
81
|
+
# -->
|
82
|
+
# Returns `self` modulo `other` as a float.
|
83
|
+
#
|
84
|
+
# For float `f` and real number `r`, these expressions are equivalent:
|
85
|
+
#
|
86
|
+
# f % r
|
87
|
+
# f-r*(f/r).floor
|
88
|
+
# f.divmod(r)[1]
|
89
|
+
#
|
90
|
+
# See Numeric#divmod.
|
91
|
+
#
|
92
|
+
# Examples:
|
93
|
+
#
|
94
|
+
# 10.0 % 2 # => 0.0
|
95
|
+
# 10.0 % 3 # => 1.0
|
96
|
+
# 10.0 % 4 # => 2.0
|
97
|
+
#
|
98
|
+
# 10.0 % -2 # => 0.0
|
99
|
+
# 10.0 % -3 # => -2.0
|
100
|
+
# 10.0 % -4 # => -2.0
|
101
|
+
#
|
102
|
+
# 10.0 % 4.0 # => 2.0
|
103
|
+
# 10.0 % Rational(4, 1) # => 2.0
|
104
|
+
#
|
105
|
+
def %: (Integer) -> Float
|
106
|
+
| (Float) -> Float
|
107
|
+
| (Rational) -> Float
|
108
|
+
| (Numeric) -> Numeric
|
109
|
+
|
110
|
+
# <!--
|
111
|
+
# rdoc-file=numeric.c
|
112
|
+
# - self * other -> numeric
|
113
|
+
# -->
|
114
|
+
# Returns a new Float which is the product of `self` and `other`:
|
115
|
+
#
|
116
|
+
# f = 3.14
|
117
|
+
# f * 2 # => 6.28
|
118
|
+
# f * 2.0 # => 6.28
|
119
|
+
# f * Rational(1, 2) # => 1.57
|
120
|
+
# f * Complex(2, 0) # => (6.28+0.0i)
|
121
|
+
#
|
122
|
+
def *: (Complex) -> Complex
|
123
|
+
| (Numeric) -> Float
|
124
|
+
|
125
|
+
# <!--
|
126
|
+
# rdoc-file=numeric.c
|
127
|
+
# - self ** other -> numeric
|
128
|
+
# -->
|
129
|
+
# Raises `self` to the power of `other`:
|
130
|
+
#
|
131
|
+
# f = 3.14
|
132
|
+
# f ** 2 # => 9.8596
|
133
|
+
# f ** -2 # => 0.1014239928597509
|
134
|
+
# f ** 2.1 # => 11.054834900588839
|
135
|
+
# f ** Rational(2, 1) # => 9.8596
|
136
|
+
# f ** Complex(2, 0) # => (9.8596+0i)
|
137
|
+
#
|
138
|
+
def **: (Complex) -> Complex
|
139
|
+
| (Numeric) -> Float
|
140
|
+
|
141
|
+
# <!--
|
142
|
+
# rdoc-file=numeric.c
|
143
|
+
# - self + other -> numeric
|
144
|
+
# -->
|
145
|
+
# Returns a new Float which is the sum of `self` and `other`:
|
146
|
+
#
|
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)
|
152
|
+
#
|
153
|
+
def +: (Complex) -> Complex
|
154
|
+
| (Numeric) -> Float
|
155
|
+
|
156
|
+
def +@: () -> Float
|
157
|
+
|
158
|
+
# <!--
|
159
|
+
# rdoc-file=numeric.c
|
160
|
+
# - self - other -> numeric
|
161
|
+
# -->
|
162
|
+
# Returns a new Float which is the difference of `self` and `other`:
|
163
|
+
#
|
164
|
+
# f = 3.14
|
165
|
+
# f - 1 # => 2.14
|
166
|
+
# f - 1.0 # => 2.14
|
167
|
+
# f - Rational(1, 1) # => 2.14
|
168
|
+
# f - Complex(1, 0) # => (2.14+0i)
|
169
|
+
#
|
170
|
+
def -: (Complex) -> Complex
|
171
|
+
| (Numeric) -> Float
|
172
|
+
|
173
|
+
# <!--
|
174
|
+
# rdoc-file=numeric.rb
|
175
|
+
# - -float -> float
|
176
|
+
# -->
|
177
|
+
# Returns `self`, negated.
|
178
|
+
#
|
179
|
+
def -@: () -> Float
|
180
|
+
|
181
|
+
# <!--
|
182
|
+
# rdoc-file=numeric.c
|
183
|
+
# - self / other -> numeric
|
184
|
+
# -->
|
185
|
+
# Returns a new Float which is the result of dividing `self` by `other`:
|
186
|
+
#
|
187
|
+
# f = 3.14
|
188
|
+
# f / 2 # => 1.57
|
189
|
+
# f / 2.0 # => 1.57
|
190
|
+
# f / Rational(2, 1) # => 1.57
|
191
|
+
# f / Complex(2, 0) # => (1.57+0.0i)
|
192
|
+
#
|
193
|
+
def /: (Complex) -> Complex
|
194
|
+
| (Numeric) -> Float
|
195
|
+
|
196
|
+
# <!--
|
197
|
+
# rdoc-file=numeric.c
|
198
|
+
# - self < other -> true or false
|
199
|
+
# -->
|
200
|
+
# Returns `true` if `self` is numerically less than `other`:
|
201
|
+
#
|
202
|
+
# 2.0 < 3 # => true
|
203
|
+
# 2.0 < 3.0 # => true
|
204
|
+
# 2.0 < Rational(3, 1) # => true
|
205
|
+
# 2.0 < 2.0 # => false
|
206
|
+
#
|
207
|
+
# `Float::NAN < Float::NAN` returns an implementation-dependent value.
|
208
|
+
#
|
209
|
+
def <: (Numeric) -> bool
|
210
|
+
|
211
|
+
# <!--
|
212
|
+
# rdoc-file=numeric.c
|
213
|
+
# - self <= other -> true or false
|
214
|
+
# -->
|
215
|
+
# Returns `true` if `self` is numerically less than or equal to `other`:
|
216
|
+
#
|
217
|
+
# 2.0 <= 3 # => true
|
218
|
+
# 2.0 <= 3.0 # => true
|
219
|
+
# 2.0 <= Rational(3, 1) # => true
|
220
|
+
# 2.0 <= 2.0 # => true
|
221
|
+
# 2.0 <= 1.0 # => false
|
222
|
+
#
|
223
|
+
# `Float::NAN <= Float::NAN` returns an implementation-dependent value.
|
224
|
+
#
|
225
|
+
def <=: (Numeric) -> bool
|
226
|
+
|
227
|
+
# <!--
|
228
|
+
# rdoc-file=numeric.c
|
229
|
+
# - self <=> other -> -1, 0, +1, or nil
|
230
|
+
# -->
|
231
|
+
# Returns a value that depends on the numeric relation between `self` and
|
232
|
+
# `other`:
|
233
|
+
#
|
234
|
+
# * -1, if `self` is less than `other`.
|
235
|
+
# * 0, if `self` is equal to `other`.
|
236
|
+
# * 1, if `self` is greater than `other`.
|
237
|
+
# * `nil`, if the two values are incommensurate.
|
238
|
+
#
|
239
|
+
# Examples:
|
240
|
+
#
|
241
|
+
# 2.0 <=> 2 # => 0
|
242
|
+
# 2.0 <=> 2.0 # => 0
|
243
|
+
# 2.0 <=> Rational(2, 1) # => 0
|
244
|
+
# 2.0 <=> Complex(2, 0) # => 0
|
245
|
+
# 2.0 <=> 1.9 # => 1
|
246
|
+
# 2.0 <=> 2.1 # => -1
|
247
|
+
# 2.0 <=> 'foo' # => nil
|
248
|
+
#
|
249
|
+
# This is the basis for the tests in the Comparable module.
|
250
|
+
#
|
251
|
+
# `Float::NAN <=> Float::NAN` returns an implementation-dependent value.
|
252
|
+
#
|
253
|
+
def <=>: (Numeric) -> Integer?
|
254
|
+
|
255
|
+
# <!--
|
256
|
+
# rdoc-file=numeric.c
|
257
|
+
# - self == other -> true or false
|
258
|
+
# -->
|
259
|
+
# Returns `true` if `other` has the same value as `self`, `false` otherwise:
|
260
|
+
#
|
261
|
+
# 2.0 == 2 # => true
|
262
|
+
# 2.0 == 2.0 # => true
|
263
|
+
# 2.0 == Rational(2, 1) # => true
|
264
|
+
# 2.0 == Complex(2, 0) # => true
|
265
|
+
#
|
266
|
+
# `Float::NAN == Float::NAN` returns an implementation-dependent value.
|
267
|
+
#
|
268
|
+
# Related: Float#eql? (requires `other` to be a Float).
|
269
|
+
#
|
270
|
+
def ==: (untyped) -> bool
|
271
|
+
|
272
|
+
# <!-- rdoc-file=numeric.c -->
|
273
|
+
# Returns `true` if `other` has the same value as `self`, `false` otherwise:
|
274
|
+
#
|
275
|
+
# 2.0 == 2 # => true
|
276
|
+
# 2.0 == 2.0 # => true
|
277
|
+
# 2.0 == Rational(2, 1) # => true
|
278
|
+
# 2.0 == Complex(2, 0) # => true
|
279
|
+
#
|
280
|
+
# `Float::NAN == Float::NAN` returns an implementation-dependent value.
|
281
|
+
#
|
282
|
+
# Related: Float#eql? (requires `other` to be a Float).
|
283
|
+
#
|
284
|
+
def ===: (untyped) -> bool
|
285
|
+
|
286
|
+
# <!--
|
287
|
+
# rdoc-file=numeric.c
|
288
|
+
# - self > other -> true or false
|
289
|
+
# -->
|
290
|
+
# Returns `true` if `self` is numerically greater than `other`:
|
291
|
+
#
|
292
|
+
# 2.0 > 1 # => true
|
293
|
+
# 2.0 > 1.0 # => true
|
294
|
+
# 2.0 > Rational(1, 2) # => true
|
295
|
+
# 2.0 > 2.0 # => false
|
296
|
+
#
|
297
|
+
# `Float::NAN > Float::NAN` returns an implementation-dependent value.
|
298
|
+
#
|
299
|
+
def >: (Numeric) -> bool
|
300
|
+
|
301
|
+
# <!--
|
302
|
+
# rdoc-file=numeric.c
|
303
|
+
# - self >= other -> true or false
|
304
|
+
# -->
|
305
|
+
# Returns `true` if `self` is numerically greater than or equal to `other`:
|
306
|
+
#
|
307
|
+
# 2.0 >= 1 # => true
|
308
|
+
# 2.0 >= 1.0 # => true
|
309
|
+
# 2.0 >= Rational(1, 2) # => true
|
310
|
+
# 2.0 >= 2.0 # => true
|
311
|
+
# 2.0 >= 2.1 # => false
|
312
|
+
#
|
313
|
+
# `Float::NAN >= Float::NAN` returns an implementation-dependent value.
|
314
|
+
#
|
315
|
+
def >=: (Numeric) -> bool
|
316
|
+
|
317
|
+
# <!--
|
318
|
+
# rdoc-file=numeric.rb
|
319
|
+
# - float.abs -> float
|
320
|
+
# -->
|
321
|
+
# Returns the absolute value of `self`:
|
322
|
+
#
|
323
|
+
# (-34.56).abs # => 34.56
|
324
|
+
# -34.56.abs # => 34.56
|
325
|
+
# 34.56.abs # => 34.56
|
326
|
+
#
|
327
|
+
def abs: () -> Float
|
328
|
+
|
329
|
+
def abs2: () -> Float
|
330
|
+
|
331
|
+
# <!-- rdoc-file=complex.c -->
|
332
|
+
# Returns 0 if `self` is positive, Math::PI otherwise.
|
333
|
+
#
|
334
|
+
def angle: () -> (Integer | Float)
|
335
|
+
|
336
|
+
# <!--
|
337
|
+
# rdoc-file=complex.c
|
338
|
+
# - arg -> 0 or Math::PI
|
339
|
+
# -->
|
340
|
+
# Returns 0 if `self` is positive, Math::PI otherwise.
|
341
|
+
#
|
342
|
+
alias arg angle
|
343
|
+
|
344
|
+
# <!--
|
345
|
+
# rdoc-file=numeric.c
|
346
|
+
# - ceil(ndigits = 0) -> float or integer
|
347
|
+
# -->
|
348
|
+
# Returns a numeric that is a "ceiling" value for `self`,
|
349
|
+
# as specified by the given `ndigits`,
|
350
|
+
# which must be an
|
351
|
+
# [integer-convertible
|
352
|
+
# object](rdoc-ref:implicit_conversion.rdoc@Integer-Convertible+Objects).
|
353
|
+
# When `ndigits` is positive, returns a Float with `ndigits`
|
354
|
+
# decimal digits after the decimal point
|
355
|
+
# (as available, but no fewer than 1):
|
356
|
+
# f = 12345.6789
|
357
|
+
# f.ceil(1) # => 12345.7
|
358
|
+
# f.ceil(3) # => 12345.679
|
359
|
+
# f.ceil(30) # => 12345.6789
|
360
|
+
# f = -12345.6789
|
361
|
+
# f.ceil(1) # => -12345.6
|
362
|
+
# f.ceil(3) # => -12345.678
|
363
|
+
# f.ceil(30) # => -12345.6789
|
364
|
+
# f = 0.0
|
365
|
+
# f.ceil(1) # => 0.0
|
366
|
+
# f.ceil(100) # => 0.0
|
367
|
+
#
|
368
|
+
# When `ndigits` is non-positive,
|
369
|
+
# returns an Integer based on a computed granularity:
|
370
|
+
# * The granularity is `10 ** ndigits.abs`.
|
371
|
+
# * The returned value is the largest multiple of the granularity
|
372
|
+
# that is less than or equal to `self`.
|
373
|
+
# Examples with positive `self`:
|
374
|
+
# ndigits|Granularity|12345.6789.ceil(ndigits)
|
375
|
+
# -------|-----------|------------------------
|
376
|
+
# 0| 1| 12346
|
377
|
+
# -1| 10| 12350
|
378
|
+
# -2| 100| 12400
|
379
|
+
# -3| 1000| 13000
|
380
|
+
# -4| 10000| 20000
|
381
|
+
# -5| 100000| 100000
|
382
|
+
# Examples with negative `self`:
|
383
|
+
# ndigits|Granularity|-12345.6789.ceil(ndigits)
|
384
|
+
# -------|-----------|-------------------------
|
385
|
+
# 0| 1| -12345
|
386
|
+
# -1| 10| -12340
|
387
|
+
# -2| 100| -12300
|
388
|
+
# -3| 1000| -12000
|
389
|
+
# -4| 10000| -10000
|
390
|
+
# -5| 100000| 0
|
391
|
+
# When `self` is zero and `ndigits` is non-positive,
|
392
|
+
# returns Integer zero:
|
393
|
+
# 0.0.ceil(0) # => 0
|
394
|
+
# 0.0.ceil(-1) # => 0
|
395
|
+
# 0.0.ceil(-2) # => 0
|
396
|
+
#
|
397
|
+
# Note that the limited precision of floating-point arithmetic
|
398
|
+
# may lead to surprising results:
|
399
|
+
# (2.1 / 0.7).ceil #=> 4 # Not 3 (because 2.1 / 0.7 # => 3.0000000000000004, not 3.0)
|
400
|
+
#
|
401
|
+
# Related: Float#floor.
|
402
|
+
#
|
403
|
+
def ceil: () -> Integer
|
404
|
+
| (int digits) -> (Integer | Float)
|
405
|
+
|
406
|
+
# <!--
|
407
|
+
# rdoc-file=numeric.c
|
408
|
+
# - coerce(other) -> array
|
409
|
+
# -->
|
410
|
+
# Returns a 2-element array containing `other` converted to a Float and `self`:
|
411
|
+
#
|
412
|
+
# f = 3.14 # => 3.14
|
413
|
+
# f.coerce(2) # => [2.0, 3.14]
|
414
|
+
# f.coerce(2.0) # => [2.0, 3.14]
|
415
|
+
# f.coerce(Rational(1, 2)) # => [0.5, 3.14]
|
416
|
+
# f.coerce(Complex(1, 0)) # => [1.0, 3.14]
|
417
|
+
#
|
418
|
+
# Raises an exception if a type conversion fails.
|
419
|
+
#
|
420
|
+
def coerce: (Numeric) -> [ Float, Float ]
|
421
|
+
|
422
|
+
def conj: () -> Float
|
423
|
+
|
424
|
+
def conjugate: () -> Float
|
425
|
+
|
426
|
+
# <!--
|
427
|
+
# rdoc-file=rational.c
|
428
|
+
# - flo.denominator -> integer
|
429
|
+
# -->
|
430
|
+
# Returns the denominator (always positive). The result is machine dependent.
|
431
|
+
#
|
432
|
+
# See also Float#numerator.
|
433
|
+
#
|
434
|
+
def denominator: () -> Integer
|
435
|
+
|
436
|
+
def div: (Numeric) -> Integer
|
437
|
+
|
438
|
+
# <!--
|
439
|
+
# rdoc-file=numeric.c
|
440
|
+
# - divmod(other) -> array
|
441
|
+
# -->
|
442
|
+
# Returns a 2-element array `[q, r]`, where
|
443
|
+
#
|
444
|
+
# q = (self/other).floor # Quotient
|
445
|
+
# r = self % other # Remainder
|
446
|
+
#
|
447
|
+
# Examples:
|
448
|
+
#
|
449
|
+
# 11.0.divmod(4) # => [2, 3.0]
|
450
|
+
# 11.0.divmod(-4) # => [-3, -1.0]
|
451
|
+
# -11.0.divmod(4) # => [-3, 1.0]
|
452
|
+
# -11.0.divmod(-4) # => [2, -3.0]
|
453
|
+
#
|
454
|
+
# 12.0.divmod(4) # => [3, 0.0]
|
455
|
+
# 12.0.divmod(-4) # => [-3, 0.0]
|
456
|
+
# -12.0.divmod(4) # => [-3, -0.0]
|
457
|
+
# -12.0.divmod(-4) # => [3, -0.0]
|
458
|
+
#
|
459
|
+
# 13.0.divmod(4.0) # => [3, 1.0]
|
460
|
+
# 13.0.divmod(Rational(4, 1)) # => [3, 1.0]
|
461
|
+
#
|
462
|
+
def divmod: (Integer | Float | Rational) -> [ Integer, Float ]
|
463
|
+
| (Numeric) -> [ Numeric, Numeric ]
|
464
|
+
|
465
|
+
def dup: () -> self
|
466
|
+
|
467
|
+
# <!--
|
468
|
+
# rdoc-file=numeric.c
|
469
|
+
# - eql?(other) -> true or false
|
470
|
+
# -->
|
471
|
+
# Returns `true` if `other` is a Float with the same value as `self`, `false`
|
472
|
+
# otherwise:
|
473
|
+
#
|
474
|
+
# 2.0.eql?(2.0) # => true
|
475
|
+
# 2.0.eql?(1.0) # => false
|
476
|
+
# 2.0.eql?(1) # => false
|
477
|
+
# 2.0.eql?(Rational(2, 1)) # => false
|
478
|
+
# 2.0.eql?(Complex(2, 0)) # => false
|
479
|
+
#
|
480
|
+
# `Float::NAN.eql?(Float::NAN)` returns an implementation-dependent value.
|
481
|
+
#
|
482
|
+
# Related: Float#== (performs type conversions).
|
483
|
+
#
|
484
|
+
def eql?: (untyped) -> bool
|
485
|
+
|
486
|
+
# <!-- rdoc-file=numeric.c -->
|
487
|
+
# Returns the quotient from dividing `self` by `other`:
|
488
|
+
#
|
489
|
+
# f = 3.14
|
490
|
+
# f.quo(2) # => 1.57
|
491
|
+
# f.quo(-2) # => -1.57
|
492
|
+
# f.quo(Rational(2, 1)) # => 1.57
|
493
|
+
# f.quo(Complex(2, 0)) # => (1.57+0.0i)
|
494
|
+
#
|
495
|
+
def fdiv: (Complex) -> Complex
|
496
|
+
| (Numeric) -> Float
|
497
|
+
|
498
|
+
# <!--
|
499
|
+
# rdoc-file=numeric.c
|
500
|
+
# - finite? -> true or false
|
501
|
+
# -->
|
502
|
+
# Returns `true` if `self` is not `Infinity`, `-Infinity`, or `NaN`, `false`
|
503
|
+
# otherwise:
|
504
|
+
#
|
505
|
+
# f = 2.0 # => 2.0
|
506
|
+
# f.finite? # => true
|
507
|
+
# f = 1.0/0.0 # => Infinity
|
508
|
+
# f.finite? # => false
|
509
|
+
# f = -1.0/0.0 # => -Infinity
|
510
|
+
# f.finite? # => false
|
511
|
+
# f = 0.0/0.0 # => NaN
|
512
|
+
# f.finite? # => false
|
513
|
+
#
|
514
|
+
def finite?: () -> bool
|
515
|
+
|
516
|
+
# <!--
|
517
|
+
# rdoc-file=numeric.c
|
518
|
+
# - floor(ndigits = 0) -> float or integer
|
519
|
+
# -->
|
520
|
+
# Returns a float or integer that is a "floor" value for `self`,
|
521
|
+
# as specified by `ndigits`,
|
522
|
+
# which must be an
|
523
|
+
# [integer-convertible
|
524
|
+
# object](rdoc-ref:implicit_conversion.rdoc@Integer-Convertible+Objects).
|
525
|
+
# When `self` is zero,
|
526
|
+
# returns a zero value:
|
527
|
+
# a float if `ndigits` is positive,
|
528
|
+
# an integer otherwise:
|
529
|
+
# f = 0.0 # => 0.0
|
530
|
+
# f.floor(20) # => 0.0
|
531
|
+
# f.floor(0) # => 0
|
532
|
+
# f.floor(-20) # => 0
|
533
|
+
#
|
534
|
+
# When `self` is non-zero and `ndigits` is positive, returns a float with
|
535
|
+
# `ndigits`
|
536
|
+
# digits after the decimal point (as available):
|
537
|
+
# f = 12345.6789
|
538
|
+
# f.floor(1) # => 12345.6
|
539
|
+
# f.floor(3) # => 12345.678
|
540
|
+
# f.floor(30) # => 12345.6789
|
541
|
+
# f = -12345.6789
|
542
|
+
# f.floor(1) # => -12345.7
|
543
|
+
# f.floor(3) # => -12345.679
|
544
|
+
# f.floor(30) # => -12345.6789
|
545
|
+
#
|
546
|
+
# When `self` is non-zero and `ndigits` is non-positive,
|
547
|
+
# returns an integer value based on a computed granularity:
|
548
|
+
# * The granularity is `10 ** ndigits.abs`.
|
549
|
+
# * The returned value is the largest multiple of the granularity
|
550
|
+
# that is less than or equal to `self`.
|
551
|
+
# Examples with positive `self`:
|
552
|
+
# ndigits|Granularity|12345.6789.floor(ndigits)
|
553
|
+
# -------|-----------|-------------------------
|
554
|
+
# 0| 1| 12345
|
555
|
+
# -1| 10| 12340
|
556
|
+
# -2| 100| 12300
|
557
|
+
# -3| 1000| 12000
|
558
|
+
# -4| 10000| 10000
|
559
|
+
# -5| 100000| 0
|
560
|
+
# Examples with negative `self`:
|
561
|
+
# ndigits|Granularity|-12345.6789.floor(ndigits)
|
562
|
+
# -------|-----------|--------------------------
|
563
|
+
# 0| 1| -12346
|
564
|
+
# -1| 10| -12350
|
565
|
+
# -2| 100| -12400
|
566
|
+
# -3| 1000| -13000
|
567
|
+
# -4| 10000| -20000
|
568
|
+
# -5| 100000| -100000
|
569
|
+
# -6| 1000000| -1000000
|
570
|
+
# Note that the limited precision of floating-point arithmetic
|
571
|
+
# may lead to surprising results:
|
572
|
+
# (0.3 / 0.1).floor # => 2 # Not 3, (because (0.3 / 0.1) # => 2.9999999999999996, not 3.0)
|
573
|
+
#
|
574
|
+
# Related: Float#ceil.
|
575
|
+
#
|
576
|
+
def floor: () -> Integer
|
577
|
+
| (int digits) -> (Integer | Numeric)
|
578
|
+
|
579
|
+
# <!--
|
580
|
+
# rdoc-file=numeric.c
|
581
|
+
# - hash -> integer
|
582
|
+
# -->
|
583
|
+
# Returns the integer hash value for `self`.
|
584
|
+
#
|
585
|
+
# See also Object#hash.
|
586
|
+
#
|
587
|
+
def hash: () -> Integer
|
588
|
+
|
589
|
+
def i: () -> Complex
|
590
|
+
|
591
|
+
def imag: () -> Integer
|
592
|
+
|
593
|
+
def imaginary: () -> Integer
|
594
|
+
|
595
|
+
# <!--
|
596
|
+
# rdoc-file=numeric.c
|
597
|
+
# - infinite? -> -1, 1, or nil
|
598
|
+
# -->
|
599
|
+
# Returns:
|
600
|
+
#
|
601
|
+
# * 1, if `self` is `Infinity`.
|
602
|
+
# * -1 if `self` is `-Infinity`.
|
603
|
+
# * `nil`, otherwise.
|
604
|
+
#
|
605
|
+
# Examples:
|
606
|
+
#
|
607
|
+
# f = 1.0/0.0 # => Infinity
|
608
|
+
# f.infinite? # => 1
|
609
|
+
# f = -1.0/0.0 # => -Infinity
|
610
|
+
# f.infinite? # => -1
|
611
|
+
# f = 1.0 # => 1.0
|
612
|
+
# f.infinite? # => nil
|
613
|
+
# f = 0.0/0.0 # => NaN
|
614
|
+
# f.infinite? # => nil
|
615
|
+
#
|
616
|
+
def infinite?: () -> Integer?
|
617
|
+
|
618
|
+
# <!-- rdoc-file=numeric.c -->
|
619
|
+
# Returns a string containing a representation of `self`; depending of the value
|
620
|
+
# of `self`, the string representation may contain:
|
621
|
+
#
|
622
|
+
# * A fixed-point number.
|
623
|
+
# 3.14.to_s # => "3.14"
|
624
|
+
#
|
625
|
+
# * A number in "scientific notation" (containing an exponent).
|
626
|
+
# (10.1**50).to_s # => "1.644631821843879e+50"
|
627
|
+
#
|
628
|
+
# * 'Infinity'.
|
629
|
+
# (10.1**500).to_s # => "Infinity"
|
630
|
+
#
|
631
|
+
# * '-Infinity'.
|
632
|
+
# (-10.1**500).to_s # => "-Infinity"
|
633
|
+
#
|
634
|
+
# * 'NaN' (indicating not-a-number).
|
635
|
+
# (0.0/0.0).to_s # => "NaN"
|
636
|
+
#
|
637
|
+
alias inspect to_s
|
638
|
+
|
639
|
+
def integer?: () -> bool
|
640
|
+
|
641
|
+
# <!--
|
642
|
+
# rdoc-file=numeric.rb
|
643
|
+
# - magnitude()
|
644
|
+
# -->
|
645
|
+
#
|
646
|
+
alias magnitude abs
|
647
|
+
|
648
|
+
# <!-- rdoc-file=numeric.c -->
|
649
|
+
# Returns `self` modulo `other` as a float.
|
650
|
+
#
|
651
|
+
# For float `f` and real number `r`, these expressions are equivalent:
|
652
|
+
#
|
653
|
+
# f % r
|
654
|
+
# f-r*(f/r).floor
|
655
|
+
# f.divmod(r)[1]
|
656
|
+
#
|
657
|
+
# See Numeric#divmod.
|
658
|
+
#
|
659
|
+
# Examples:
|
660
|
+
#
|
661
|
+
# 10.0 % 2 # => 0.0
|
662
|
+
# 10.0 % 3 # => 1.0
|
663
|
+
# 10.0 % 4 # => 2.0
|
664
|
+
#
|
665
|
+
# 10.0 % -2 # => 0.0
|
666
|
+
# 10.0 % -3 # => -2.0
|
667
|
+
# 10.0 % -4 # => -2.0
|
668
|
+
#
|
669
|
+
# 10.0 % 4.0 # => 2.0
|
670
|
+
# 10.0 % Rational(4, 1) # => 2.0
|
671
|
+
#
|
672
|
+
def modulo: (Numeric) -> Float
|
673
|
+
|
674
|
+
# <!--
|
675
|
+
# rdoc-file=numeric.c
|
676
|
+
# - nan? -> true or false
|
677
|
+
# -->
|
678
|
+
# Returns `true` if `self` is a NaN, `false` otherwise.
|
679
|
+
#
|
680
|
+
# f = -1.0 #=> -1.0
|
681
|
+
# f.nan? #=> false
|
682
|
+
# f = 0.0/0.0 #=> NaN
|
683
|
+
# f.nan? #=> true
|
684
|
+
#
|
685
|
+
def nan?: () -> bool
|
686
|
+
|
687
|
+
# <!--
|
688
|
+
# rdoc-file=numeric.rb
|
689
|
+
# - negative? -> true or false
|
690
|
+
# -->
|
691
|
+
# Returns `true` if `self` is less than 0, `false` otherwise.
|
692
|
+
#
|
693
|
+
def negative?: () -> bool
|
694
|
+
|
695
|
+
# <!--
|
696
|
+
# rdoc-file=numeric.c
|
697
|
+
# - next_float -> float
|
698
|
+
# -->
|
699
|
+
# Returns the next-larger representable Float.
|
700
|
+
#
|
701
|
+
# These examples show the internally stored values (64-bit hexadecimal) for each
|
702
|
+
# Float `f` and for the corresponding `f.next_float`:
|
703
|
+
#
|
704
|
+
# f = 0.0 # 0x0000000000000000
|
705
|
+
# f.next_float # 0x0000000000000001
|
706
|
+
#
|
707
|
+
# f = 0.01 # 0x3f847ae147ae147b
|
708
|
+
# f.next_float # 0x3f847ae147ae147c
|
709
|
+
#
|
710
|
+
# In the remaining examples here, the output is shown in the usual way (result
|
711
|
+
# `to_s`):
|
712
|
+
#
|
713
|
+
# 0.01.next_float # => 0.010000000000000002
|
714
|
+
# 1.0.next_float # => 1.0000000000000002
|
715
|
+
# 100.0.next_float # => 100.00000000000001
|
716
|
+
#
|
717
|
+
# f = 0.01
|
718
|
+
# (0..3).each_with_index {|i| printf "%2d %-20a %s\n", i, f, f.to_s; f = f.next_float }
|
719
|
+
#
|
720
|
+
# Output:
|
721
|
+
#
|
722
|
+
# 0 0x1.47ae147ae147bp-7 0.01
|
723
|
+
# 1 0x1.47ae147ae147cp-7 0.010000000000000002
|
724
|
+
# 2 0x1.47ae147ae147dp-7 0.010000000000000004
|
725
|
+
# 3 0x1.47ae147ae147ep-7 0.010000000000000005
|
726
|
+
#
|
727
|
+
# f = 0.0; 100.times { f += 0.1 }
|
728
|
+
# f # => 9.99999999999998 # should be 10.0 in the ideal world.
|
729
|
+
# 10-f # => 1.9539925233402755e-14 # the floating point error.
|
730
|
+
# 10.0.next_float-10 # => 1.7763568394002505e-15 # 1 ulp (unit in the last place).
|
731
|
+
# (10-f)/(10.0.next_float-10) # => 11.0 # the error is 11 ulp.
|
732
|
+
# (10-f)/(10*Float::EPSILON) # => 8.8 # approximation of the above.
|
733
|
+
# "%a" % 10 # => "0x1.4p+3"
|
734
|
+
# "%a" % f # => "0x1.3fffffffffff5p+3" # the last hex digit is 5. 16 - 5 = 11 ulp.
|
735
|
+
#
|
736
|
+
# Related: Float#prev_float
|
737
|
+
#
|
738
|
+
def next_float: () -> Float
|
739
|
+
|
740
|
+
def nonzero?: () -> self?
|
741
|
+
|
742
|
+
# <!--
|
743
|
+
# rdoc-file=rational.c
|
744
|
+
# - flo.numerator -> integer
|
745
|
+
# -->
|
746
|
+
# Returns the numerator. The result is machine dependent.
|
747
|
+
#
|
748
|
+
# n = 0.3.numerator #=> 5404319552844595
|
749
|
+
# d = 0.3.denominator #=> 18014398509481984
|
750
|
+
# n.fdiv(d) #=> 0.3
|
751
|
+
#
|
752
|
+
# See also Float#denominator.
|
753
|
+
#
|
754
|
+
def numerator: () -> Integer
|
755
|
+
|
756
|
+
# <!-- rdoc-file=complex.c -->
|
757
|
+
# Returns 0 if `self` is positive, Math::PI otherwise.
|
758
|
+
#
|
759
|
+
alias phase angle
|
760
|
+
|
761
|
+
def polar: () -> [ Float, Integer | Float ]
|
762
|
+
|
763
|
+
# <!--
|
764
|
+
# rdoc-file=numeric.rb
|
765
|
+
# - positive? -> true or false
|
766
|
+
# -->
|
767
|
+
# Returns `true` if `self` is greater than 0, `false` otherwise.
|
768
|
+
#
|
769
|
+
def positive?: () -> bool
|
770
|
+
|
771
|
+
# <!--
|
772
|
+
# rdoc-file=numeric.c
|
773
|
+
# - float.prev_float -> float
|
774
|
+
# -->
|
775
|
+
# Returns the next-smaller representable Float.
|
776
|
+
#
|
777
|
+
# These examples show the internally stored values (64-bit hexadecimal) for each
|
778
|
+
# Float `f` and for the corresponding `f.pev_float`:
|
779
|
+
#
|
780
|
+
# f = 5e-324 # 0x0000000000000001
|
781
|
+
# f.prev_float # 0x0000000000000000
|
782
|
+
#
|
783
|
+
# f = 0.01 # 0x3f847ae147ae147b
|
784
|
+
# f.prev_float # 0x3f847ae147ae147a
|
785
|
+
#
|
786
|
+
# In the remaining examples here, the output is shown in the usual way (result
|
787
|
+
# `to_s`):
|
788
|
+
#
|
789
|
+
# 0.01.prev_float # => 0.009999999999999998
|
790
|
+
# 1.0.prev_float # => 0.9999999999999999
|
791
|
+
# 100.0.prev_float # => 99.99999999999999
|
792
|
+
#
|
793
|
+
# f = 0.01
|
794
|
+
# (0..3).each_with_index {|i| printf "%2d %-20a %s\n", i, f, f.to_s; f = f.prev_float }
|
795
|
+
#
|
796
|
+
# Output:
|
797
|
+
#
|
798
|
+
# 0 0x1.47ae147ae147bp-7 0.01
|
799
|
+
# 1 0x1.47ae147ae147ap-7 0.009999999999999998
|
800
|
+
# 2 0x1.47ae147ae1479p-7 0.009999999999999997
|
801
|
+
# 3 0x1.47ae147ae1478p-7 0.009999999999999995
|
802
|
+
#
|
803
|
+
# Related: Float#next_float.
|
804
|
+
#
|
805
|
+
def prev_float: () -> Float
|
806
|
+
|
807
|
+
# <!--
|
808
|
+
# rdoc-file=numeric.c
|
809
|
+
# - quo(other) -> numeric
|
810
|
+
# -->
|
811
|
+
# Returns the quotient from dividing `self` by `other`:
|
812
|
+
#
|
813
|
+
# f = 3.14
|
814
|
+
# f.quo(2) # => 1.57
|
815
|
+
# f.quo(-2) # => -1.57
|
816
|
+
# f.quo(Rational(2, 1)) # => 1.57
|
817
|
+
# f.quo(Complex(2, 0)) # => (1.57+0.0i)
|
818
|
+
#
|
819
|
+
def quo: (Complex) -> Complex
|
820
|
+
| (Numeric) -> Float
|
821
|
+
|
822
|
+
# <!--
|
823
|
+
# rdoc-file=rational.c
|
824
|
+
# - flt.rationalize([eps]) -> rational
|
825
|
+
# -->
|
826
|
+
# Returns a simpler approximation of the value (flt-|eps| <= result <=
|
827
|
+
# flt+|eps|). If the optional argument `eps` is not given, it will be chosen
|
828
|
+
# automatically.
|
829
|
+
#
|
830
|
+
# 0.3.rationalize #=> (3/10)
|
831
|
+
# 1.333.rationalize #=> (1333/1000)
|
832
|
+
# 1.333.rationalize(0.01) #=> (4/3)
|
833
|
+
#
|
834
|
+
# See also Float#to_r.
|
835
|
+
#
|
836
|
+
def rationalize: (?Numeric eps) -> Rational
|
837
|
+
|
838
|
+
def real: () -> Float
|
839
|
+
|
840
|
+
def real?: () -> true
|
841
|
+
|
842
|
+
def rect: () -> [ Float, Numeric ]
|
843
|
+
|
844
|
+
alias rectangular rect
|
845
|
+
|
846
|
+
def remainder: (Numeric) -> Float
|
847
|
+
|
848
|
+
# <!--
|
849
|
+
# rdoc-file=numeric.c
|
850
|
+
# - round(ndigits = 0, half: :up) -> integer or float
|
851
|
+
# -->
|
852
|
+
# Returns `self` rounded to the nearest value with a precision of `ndigits`
|
853
|
+
# decimal digits.
|
854
|
+
#
|
855
|
+
# When `ndigits` is non-negative, returns a float with `ndigits` after the
|
856
|
+
# decimal point (as available):
|
857
|
+
#
|
858
|
+
# f = 12345.6789
|
859
|
+
# f.round(1) # => 12345.7
|
860
|
+
# f.round(3) # => 12345.679
|
861
|
+
# f = -12345.6789
|
862
|
+
# f.round(1) # => -12345.7
|
863
|
+
# f.round(3) # => -12345.679
|
864
|
+
#
|
865
|
+
# When `ndigits` is negative, returns an integer with at least `ndigits.abs`
|
866
|
+
# trailing zeros:
|
867
|
+
#
|
868
|
+
# f = 12345.6789
|
869
|
+
# f.round(0) # => 12346
|
870
|
+
# f.round(-3) # => 12000
|
871
|
+
# f = -12345.6789
|
872
|
+
# f.round(0) # => -12346
|
873
|
+
# f.round(-3) # => -12000
|
874
|
+
#
|
875
|
+
# If keyword argument `half` is given, and `self` is equidistant from the two
|
876
|
+
# candidate values, the rounding is according to the given `half` value:
|
877
|
+
#
|
878
|
+
# * `:up` or `nil`: round away from zero:
|
879
|
+
#
|
880
|
+
# 2.5.round(half: :up) # => 3
|
881
|
+
# 3.5.round(half: :up) # => 4
|
882
|
+
# (-2.5).round(half: :up) # => -3
|
883
|
+
#
|
884
|
+
# * `:down`: round toward zero:
|
885
|
+
#
|
886
|
+
# 2.5.round(half: :down) # => 2
|
887
|
+
# 3.5.round(half: :down) # => 3
|
888
|
+
# (-2.5).round(half: :down) # => -2
|
889
|
+
#
|
890
|
+
# * `:even`: round toward the candidate whose last nonzero digit is even:
|
891
|
+
#
|
892
|
+
# 2.5.round(half: :even) # => 2
|
893
|
+
# 3.5.round(half: :even) # => 4
|
894
|
+
# (-2.5).round(half: :even) # => -2
|
895
|
+
#
|
896
|
+
# Raises and exception if the value for `half` is invalid.
|
897
|
+
#
|
898
|
+
# Related: Float#truncate.
|
899
|
+
#
|
900
|
+
def round: (?half: :up | :down | :even) -> Integer
|
901
|
+
| (int digits, ?half: :up | :down | :even) -> (Integer | Float)
|
902
|
+
|
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
|
+
# <!--
|
911
|
+
# rdoc-file=numeric.rb
|
912
|
+
# - to_f -> self
|
913
|
+
# -->
|
914
|
+
# Returns `self` (which is already a Float).
|
915
|
+
#
|
916
|
+
def to_f: () -> Float
|
917
|
+
|
918
|
+
# <!--
|
919
|
+
# rdoc-file=numeric.c
|
920
|
+
# - to_i -> integer
|
921
|
+
# -->
|
922
|
+
# Returns `self` truncated to an Integer.
|
923
|
+
#
|
924
|
+
# 1.2.to_i # => 1
|
925
|
+
# (-1.2).to_i # => -1
|
926
|
+
#
|
927
|
+
# Note that the limited precision of floating-point arithmetic may lead to
|
928
|
+
# surprising results:
|
929
|
+
#
|
930
|
+
# (0.3 / 0.1).to_i # => 2 (!)
|
931
|
+
#
|
932
|
+
def to_i: () -> Integer
|
933
|
+
|
934
|
+
# <!-- rdoc-file=numeric.c -->
|
935
|
+
# Returns `self` truncated to an Integer.
|
936
|
+
#
|
937
|
+
# 1.2.to_i # => 1
|
938
|
+
# (-1.2).to_i # => -1
|
939
|
+
#
|
940
|
+
# Note that the limited precision of floating-point arithmetic may lead to
|
941
|
+
# surprising results:
|
942
|
+
#
|
943
|
+
# (0.3 / 0.1).to_i # => 2 (!)
|
944
|
+
#
|
945
|
+
alias to_int to_i
|
946
|
+
|
947
|
+
# <!--
|
948
|
+
# rdoc-file=rational.c
|
949
|
+
# - flt.to_r -> rational
|
950
|
+
# -->
|
951
|
+
# Returns the value as a rational.
|
952
|
+
#
|
953
|
+
# 2.0.to_r #=> (2/1)
|
954
|
+
# 2.5.to_r #=> (5/2)
|
955
|
+
# -0.75.to_r #=> (-3/4)
|
956
|
+
# 0.0.to_r #=> (0/1)
|
957
|
+
# 0.3.to_r #=> (5404319552844595/18014398509481984)
|
958
|
+
#
|
959
|
+
# NOTE: 0.3.to_r isn't the same as "0.3".to_r. The latter is equivalent to
|
960
|
+
# "3/10".to_r, but the former isn't so.
|
961
|
+
#
|
962
|
+
# 0.3.to_r == 3/10r #=> false
|
963
|
+
# "0.3".to_r == 3/10r #=> true
|
964
|
+
#
|
965
|
+
# See also Float#rationalize.
|
966
|
+
#
|
967
|
+
def to_r: () -> Rational
|
968
|
+
|
969
|
+
# <!--
|
970
|
+
# rdoc-file=numeric.c
|
971
|
+
# - to_s -> string
|
972
|
+
# -->
|
973
|
+
# Returns a string containing a representation of `self`; depending of the value
|
974
|
+
# of `self`, the string representation may contain:
|
975
|
+
#
|
976
|
+
# * A fixed-point number.
|
977
|
+
# 3.14.to_s # => "3.14"
|
978
|
+
#
|
979
|
+
# * A number in "scientific notation" (containing an exponent).
|
980
|
+
# (10.1**50).to_s # => "1.644631821843879e+50"
|
981
|
+
#
|
982
|
+
# * 'Infinity'.
|
983
|
+
# (10.1**500).to_s # => "Infinity"
|
984
|
+
#
|
985
|
+
# * '-Infinity'.
|
986
|
+
# (-10.1**500).to_s # => "-Infinity"
|
987
|
+
#
|
988
|
+
# * 'NaN' (indicating not-a-number).
|
989
|
+
# (0.0/0.0).to_s # => "NaN"
|
990
|
+
#
|
991
|
+
def to_s: () -> String
|
992
|
+
|
993
|
+
# <!--
|
994
|
+
# rdoc-file=numeric.c
|
995
|
+
# - truncate(ndigits = 0) -> float or integer
|
996
|
+
# -->
|
997
|
+
# Returns `self` truncated (toward zero) to a precision of `ndigits` decimal
|
998
|
+
# digits.
|
999
|
+
#
|
1000
|
+
# When `ndigits` is positive, returns a float with `ndigits` digits after the
|
1001
|
+
# decimal point (as available):
|
1002
|
+
#
|
1003
|
+
# f = 12345.6789
|
1004
|
+
# f.truncate(1) # => 12345.6
|
1005
|
+
# f.truncate(3) # => 12345.678
|
1006
|
+
# f = -12345.6789
|
1007
|
+
# f.truncate(1) # => -12345.6
|
1008
|
+
# f.truncate(3) # => -12345.678
|
1009
|
+
#
|
1010
|
+
# When `ndigits` is negative, returns an integer with at least `ndigits.abs`
|
1011
|
+
# trailing zeros:
|
1012
|
+
#
|
1013
|
+
# f = 12345.6789
|
1014
|
+
# f.truncate(0) # => 12345
|
1015
|
+
# f.truncate(-3) # => 12000
|
1016
|
+
# f = -12345.6789
|
1017
|
+
# f.truncate(0) # => -12345
|
1018
|
+
# f.truncate(-3) # => -12000
|
1019
|
+
#
|
1020
|
+
# Note that the limited precision of floating-point arithmetic may lead to
|
1021
|
+
# surprising results:
|
1022
|
+
#
|
1023
|
+
# (0.3 / 0.1).truncate #=> 2 (!)
|
1024
|
+
#
|
1025
|
+
# Related: Float#round.
|
1026
|
+
#
|
1027
|
+
def truncate: () -> Integer
|
1028
|
+
| (Integer ndigits) -> (Integer | Float)
|
1029
|
+
|
1030
|
+
# <!--
|
1031
|
+
# rdoc-file=numeric.rb
|
1032
|
+
# - zero? -> true or false
|
1033
|
+
# -->
|
1034
|
+
# Returns `true` if `self` is 0.0, `false` otherwise.
|
1035
|
+
#
|
1036
|
+
def zero?: () -> bool
|
1037
|
+
end
|
1038
|
+
|
1039
|
+
# <!-- rdoc-file=numeric.c -->
|
1040
|
+
# The minimum number of significant decimal digits in a double-precision
|
1041
|
+
# floating point.
|
1042
|
+
#
|
1043
|
+
# Usually defaults to 15.
|
1044
|
+
#
|
1045
|
+
Float::DIG: Integer
|
1046
|
+
|
1047
|
+
# <!-- rdoc-file=numeric.c -->
|
1048
|
+
# The difference between 1 and the smallest double-precision floating point
|
1049
|
+
# number greater than 1.
|
1050
|
+
#
|
1051
|
+
# Usually defaults to 2.2204460492503131e-16.
|
1052
|
+
#
|
1053
|
+
Float::EPSILON: Float
|
1054
|
+
|
1055
|
+
# <!-- rdoc-file=numeric.c -->
|
1056
|
+
# An expression representing positive infinity.
|
1057
|
+
#
|
1058
|
+
Float::INFINITY: Float
|
1059
|
+
|
1060
|
+
Float::Infinity: Float
|
1061
|
+
|
1062
|
+
# <!-- rdoc-file=numeric.c -->
|
1063
|
+
# The number of base digits for the `double` data type.
|
1064
|
+
#
|
1065
|
+
# Usually defaults to 53.
|
1066
|
+
#
|
1067
|
+
Float::MANT_DIG: Integer
|
1068
|
+
|
1069
|
+
# <!-- rdoc-file=numeric.c -->
|
1070
|
+
# The largest possible integer in a double-precision floating point number.
|
1071
|
+
#
|
1072
|
+
# Usually defaults to 1.7976931348623157e+308.
|
1073
|
+
#
|
1074
|
+
Float::MAX: Float
|
1075
|
+
|
1076
|
+
# <!-- rdoc-file=numeric.c -->
|
1077
|
+
# The largest positive exponent in a double-precision floating point where 10
|
1078
|
+
# raised to this power minus 1.
|
1079
|
+
#
|
1080
|
+
# Usually defaults to 308.
|
1081
|
+
#
|
1082
|
+
Float::MAX_10_EXP: Integer
|
1083
|
+
|
1084
|
+
# <!-- rdoc-file=numeric.c -->
|
1085
|
+
# The largest possible exponent value in a double-precision floating point.
|
1086
|
+
#
|
1087
|
+
# Usually defaults to 1024.
|
1088
|
+
#
|
1089
|
+
Float::MAX_EXP: Integer
|
1090
|
+
|
1091
|
+
# <!-- rdoc-file=numeric.c -->
|
1092
|
+
# The smallest positive normalized number in a double-precision floating point.
|
1093
|
+
#
|
1094
|
+
# Usually defaults to 2.2250738585072014e-308.
|
1095
|
+
#
|
1096
|
+
# 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
|
1098
|
+
# number including denormalized numbers.
|
1099
|
+
#
|
1100
|
+
Float::MIN: Float
|
1101
|
+
|
1102
|
+
# <!-- rdoc-file=numeric.c -->
|
1103
|
+
# The smallest negative exponent in a double-precision floating point where 10
|
1104
|
+
# raised to this power minus 1.
|
1105
|
+
#
|
1106
|
+
# Usually defaults to -307.
|
1107
|
+
#
|
1108
|
+
Float::MIN_10_EXP: Integer
|
1109
|
+
|
1110
|
+
# <!-- rdoc-file=numeric.c -->
|
1111
|
+
# The smallest possible exponent value in a double-precision floating point.
|
1112
|
+
#
|
1113
|
+
# Usually defaults to -1021.
|
1114
|
+
#
|
1115
|
+
Float::MIN_EXP: Integer
|
1116
|
+
|
1117
|
+
# <!-- rdoc-file=numeric.c -->
|
1118
|
+
# An expression representing a value which is "not a number".
|
1119
|
+
#
|
1120
|
+
Float::NAN: Float
|
1121
|
+
|
1122
|
+
# <!-- rdoc-file=numeric.c -->
|
1123
|
+
# The base of the floating point, or number of unique digits used to represent
|
1124
|
+
# the number.
|
1125
|
+
#
|
1126
|
+
# Usually defaults to 2 on most systems, which would represent a base-10
|
1127
|
+
# decimal.
|
1128
|
+
#
|
1129
|
+
Float::RADIX: Integer
|
1130
|
+
|
1131
|
+
# Deprecated, do not use.
|
1132
|
+
#
|
1133
|
+
# Represents the rounding mode for floating point addition at the start time.
|
1134
|
+
#
|
1135
|
+
# Usually defaults to 1, rounding to the nearest number.
|
1136
|
+
#
|
1137
|
+
# Other modes include:
|
1138
|
+
#
|
1139
|
+
# -1
|
1140
|
+
# : Indeterminable
|
1141
|
+
# 0
|
1142
|
+
# : Rounding towards zero
|
1143
|
+
# 1
|
1144
|
+
# : Rounding to the nearest number
|
1145
|
+
# 2
|
1146
|
+
# : Rounding towards positive infinity
|
1147
|
+
# 3
|
1148
|
+
# : Rounding towards negative infinity
|
1149
|
+
#
|
1150
|
+
#
|
1151
|
+
Float::ROUNDS: Integer
|