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
@@ -0,0 +1,1629 @@
|
|
1
|
+
class BigDecimal < Numeric
|
2
|
+
# <!--
|
3
|
+
# rdoc-file=ext/bigdecimal/bigdecimal.c
|
4
|
+
# - _load(p1)
|
5
|
+
# -->
|
6
|
+
# Internal method used to provide marshalling support. See the Marshal module.
|
7
|
+
#
|
8
|
+
def self._load: (String) -> BigDecimal
|
9
|
+
|
10
|
+
# <!--
|
11
|
+
# rdoc-file=ext/bigdecimal/bigdecimal.c
|
12
|
+
# - BigDecimal.double_fig -> integer
|
13
|
+
# -->
|
14
|
+
# Returns the number of digits a Float object is allowed to have; the result is
|
15
|
+
# system-dependent:
|
16
|
+
#
|
17
|
+
# BigDecimal.double_fig # => 16
|
18
|
+
#
|
19
|
+
def self.double_fig: () -> Integer
|
20
|
+
|
21
|
+
# <!--
|
22
|
+
# rdoc-file=ext/bigdecimal/bigdecimal.c
|
23
|
+
# - interpret_loosely(p1)
|
24
|
+
# -->
|
25
|
+
#
|
26
|
+
def self.interpret_loosely: (string) -> BigDecimal
|
27
|
+
|
28
|
+
# <!--
|
29
|
+
# rdoc-file=ext/bigdecimal/bigdecimal.c
|
30
|
+
# - BigDecimal.limit(digits)
|
31
|
+
# -->
|
32
|
+
# Limit the number of significant digits in newly created BigDecimal numbers to
|
33
|
+
# the specified value. Rounding is performed as necessary, as specified by
|
34
|
+
# BigDecimal.mode.
|
35
|
+
#
|
36
|
+
# A limit of 0, the default, means no upper limit.
|
37
|
+
#
|
38
|
+
# The limit specified by this method takes less priority over any limit
|
39
|
+
# specified to instance methods such as ceil, floor, truncate, or round.
|
40
|
+
#
|
41
|
+
def self.limit: (?Integer? digits) -> Integer
|
42
|
+
|
43
|
+
# <!--
|
44
|
+
# rdoc-file=ext/bigdecimal/bigdecimal.c
|
45
|
+
# - BigDecimal.mode(mode, setting = nil) -> integer
|
46
|
+
# -->
|
47
|
+
# Returns an integer representing the mode settings for exception handling and
|
48
|
+
# rounding.
|
49
|
+
#
|
50
|
+
# These modes control exception handling:
|
51
|
+
#
|
52
|
+
# * BigDecimal::EXCEPTION_NaN.
|
53
|
+
# * BigDecimal::EXCEPTION_INFINITY.
|
54
|
+
# * BigDecimal::EXCEPTION_UNDERFLOW.
|
55
|
+
# * BigDecimal::EXCEPTION_OVERFLOW.
|
56
|
+
# * BigDecimal::EXCEPTION_ZERODIVIDE.
|
57
|
+
# * BigDecimal::EXCEPTION_ALL.
|
58
|
+
#
|
59
|
+
# Values for `setting` for exception handling:
|
60
|
+
#
|
61
|
+
# * `true`: sets the given `mode` to `true`.
|
62
|
+
# * `false`: sets the given `mode` to `false`.
|
63
|
+
# * `nil`: does not modify the mode settings.
|
64
|
+
#
|
65
|
+
# You can use method BigDecimal.save_exception_mode to temporarily change, and
|
66
|
+
# then automatically restore, exception modes.
|
67
|
+
#
|
68
|
+
# For clarity, some examples below begin by setting all exception modes to
|
69
|
+
# `false`.
|
70
|
+
#
|
71
|
+
# This mode controls the way rounding is to be performed:
|
72
|
+
#
|
73
|
+
# * BigDecimal::ROUND_MODE
|
74
|
+
#
|
75
|
+
# You can use method BigDecimal.save_rounding_mode to temporarily change, and
|
76
|
+
# then automatically restore, the rounding mode.
|
77
|
+
#
|
78
|
+
# **NaNs**
|
79
|
+
#
|
80
|
+
# Mode BigDecimal::EXCEPTION_NaN controls behavior when a BigDecimal NaN is
|
81
|
+
# created.
|
82
|
+
#
|
83
|
+
# Settings:
|
84
|
+
#
|
85
|
+
# * `false` (default): Returns `BigDecimal('NaN')`.
|
86
|
+
# * `true`: Raises FloatDomainError.
|
87
|
+
#
|
88
|
+
# Examples:
|
89
|
+
#
|
90
|
+
# BigDecimal.mode(BigDecimal::EXCEPTION_ALL, false) # => 0
|
91
|
+
# BigDecimal('NaN') # => NaN
|
92
|
+
# BigDecimal.mode(BigDecimal::EXCEPTION_NaN, true) # => 2
|
93
|
+
# BigDecimal('NaN') # Raises FloatDomainError
|
94
|
+
#
|
95
|
+
# **Infinities**
|
96
|
+
#
|
97
|
+
# Mode BigDecimal::EXCEPTION_INFINITY controls behavior when a BigDecimal
|
98
|
+
# Infinity or -Infinity is created. Settings:
|
99
|
+
#
|
100
|
+
# * `false` (default): Returns `BigDecimal('Infinity')` or
|
101
|
+
# `BigDecimal('-Infinity')`.
|
102
|
+
# * `true`: Raises FloatDomainError.
|
103
|
+
#
|
104
|
+
# Examples:
|
105
|
+
#
|
106
|
+
# BigDecimal.mode(BigDecimal::EXCEPTION_ALL, false) # => 0
|
107
|
+
# BigDecimal('Infinity') # => Infinity
|
108
|
+
# BigDecimal('-Infinity') # => -Infinity
|
109
|
+
# BigDecimal.mode(BigDecimal::EXCEPTION_INFINITY, true) # => 1
|
110
|
+
# BigDecimal('Infinity') # Raises FloatDomainError
|
111
|
+
# BigDecimal('-Infinity') # Raises FloatDomainError
|
112
|
+
#
|
113
|
+
# **Underflow**
|
114
|
+
#
|
115
|
+
# Mode BigDecimal::EXCEPTION_UNDERFLOW controls behavior when a BigDecimal
|
116
|
+
# underflow occurs. Settings:
|
117
|
+
#
|
118
|
+
# * `false` (default): Returns `BigDecimal('0')` or `BigDecimal('-Infinity')`.
|
119
|
+
# * `true`: Raises FloatDomainError.
|
120
|
+
#
|
121
|
+
# Examples:
|
122
|
+
#
|
123
|
+
# BigDecimal.mode(BigDecimal::EXCEPTION_ALL, false) # => 0
|
124
|
+
# def flow_under
|
125
|
+
# x = BigDecimal('0.1')
|
126
|
+
# 100.times { x *= x }
|
127
|
+
# end
|
128
|
+
# flow_under # => 100
|
129
|
+
# BigDecimal.mode(BigDecimal::EXCEPTION_UNDERFLOW, true) # => 4
|
130
|
+
# flow_under # Raises FloatDomainError
|
131
|
+
#
|
132
|
+
# **Overflow**
|
133
|
+
#
|
134
|
+
# Mode BigDecimal::EXCEPTION_OVERFLOW controls behavior when a BigDecimal
|
135
|
+
# overflow occurs. Settings:
|
136
|
+
#
|
137
|
+
# * `false` (default): Returns `BigDecimal('Infinity')` or
|
138
|
+
# `BigDecimal('-Infinity')`.
|
139
|
+
# * `true`: Raises FloatDomainError.
|
140
|
+
#
|
141
|
+
# Examples:
|
142
|
+
#
|
143
|
+
# BigDecimal.mode(BigDecimal::EXCEPTION_ALL, false) # => 0
|
144
|
+
# def flow_over
|
145
|
+
# x = BigDecimal('10')
|
146
|
+
# 100.times { x *= x }
|
147
|
+
# end
|
148
|
+
# flow_over # => 100
|
149
|
+
# BigDecimal.mode(BigDecimal::EXCEPTION_OVERFLOW, true) # => 1
|
150
|
+
# flow_over # Raises FloatDomainError
|
151
|
+
#
|
152
|
+
# **Zero Division**
|
153
|
+
#
|
154
|
+
# Mode BigDecimal::EXCEPTION_ZERODIVIDE controls behavior when a zero-division
|
155
|
+
# occurs. Settings:
|
156
|
+
#
|
157
|
+
# * `false` (default): Returns `BigDecimal('Infinity')` or
|
158
|
+
# `BigDecimal('-Infinity')`.
|
159
|
+
# * `true`: Raises FloatDomainError.
|
160
|
+
#
|
161
|
+
# Examples:
|
162
|
+
#
|
163
|
+
# BigDecimal.mode(BigDecimal::EXCEPTION_ALL, false) # => 0
|
164
|
+
# one = BigDecimal('1')
|
165
|
+
# zero = BigDecimal('0')
|
166
|
+
# one / zero # => Infinity
|
167
|
+
# BigDecimal.mode(BigDecimal::EXCEPTION_ZERODIVIDE, true) # => 16
|
168
|
+
# one / zero # Raises FloatDomainError
|
169
|
+
#
|
170
|
+
# **All Exceptions**
|
171
|
+
#
|
172
|
+
# Mode BigDecimal::EXCEPTION_ALL controls all of the above:
|
173
|
+
#
|
174
|
+
# BigDecimal.mode(BigDecimal::EXCEPTION_ALL, false) # => 0
|
175
|
+
# BigDecimal.mode(BigDecimal::EXCEPTION_ALL, true) # => 23
|
176
|
+
#
|
177
|
+
# **Rounding**
|
178
|
+
#
|
179
|
+
# Mode BigDecimal::ROUND_MODE controls the way rounding is to be performed; its
|
180
|
+
# `setting` values are:
|
181
|
+
#
|
182
|
+
# * `ROUND_UP`: Round away from zero. Aliased as `:up`.
|
183
|
+
# * `ROUND_DOWN`: Round toward zero. Aliased as `:down` and `:truncate`.
|
184
|
+
# * `ROUND_HALF_UP`: Round toward the nearest neighbor; if the neighbors are
|
185
|
+
# equidistant, round away from zero. Aliased as `:half_up` and `:default`.
|
186
|
+
# * `ROUND_HALF_DOWN`: Round toward the nearest neighbor; if the neighbors are
|
187
|
+
# equidistant, round toward zero. Aliased as `:half_down`.
|
188
|
+
# * `ROUND_HALF_EVEN` (Banker's rounding): Round toward the nearest neighbor;
|
189
|
+
# if the neighbors are equidistant, round toward the even neighbor. Aliased
|
190
|
+
# as `:half_even` and `:banker`.
|
191
|
+
# * `ROUND_CEILING`: Round toward positive infinity. Aliased as `:ceiling` and
|
192
|
+
# `:ceil`.
|
193
|
+
# * `ROUND_FLOOR`: Round toward negative infinity. Aliased as `:floor:`.
|
194
|
+
#
|
195
|
+
def self.mode: (Integer mode, ?Integer? value) -> Integer?
|
196
|
+
|
197
|
+
# <!--
|
198
|
+
# rdoc-file=ext/bigdecimal/bigdecimal.c
|
199
|
+
# - BigDecimal.save_exception_mode { ... }
|
200
|
+
# -->
|
201
|
+
# Execute the provided block, but preserve the exception mode
|
202
|
+
#
|
203
|
+
# BigDecimal.save_exception_mode do
|
204
|
+
# BigDecimal.mode(BigDecimal::EXCEPTION_OVERFLOW, false)
|
205
|
+
# BigDecimal.mode(BigDecimal::EXCEPTION_NaN, false)
|
206
|
+
#
|
207
|
+
# BigDecimal(BigDecimal('Infinity'))
|
208
|
+
# BigDecimal(BigDecimal('-Infinity'))
|
209
|
+
# BigDecimal(BigDecimal('NaN'))
|
210
|
+
# end
|
211
|
+
#
|
212
|
+
# For use with the BigDecimal::EXCEPTION_*
|
213
|
+
#
|
214
|
+
# See BigDecimal.mode
|
215
|
+
#
|
216
|
+
def self.save_exception_mode: () { (?nil) -> void } -> void
|
217
|
+
|
218
|
+
# <!--
|
219
|
+
# rdoc-file=ext/bigdecimal/bigdecimal.c
|
220
|
+
# - BigDecimal.save_limit { ... }
|
221
|
+
# -->
|
222
|
+
# Execute the provided block, but preserve the precision limit
|
223
|
+
#
|
224
|
+
# BigDecimal.limit(100)
|
225
|
+
# puts BigDecimal.limit
|
226
|
+
# BigDecimal.save_limit do
|
227
|
+
# BigDecimal.limit(200)
|
228
|
+
# puts BigDecimal.limit
|
229
|
+
# end
|
230
|
+
# puts BigDecimal.limit
|
231
|
+
#
|
232
|
+
def self.save_limit: () { (?nil) -> void } -> void
|
233
|
+
|
234
|
+
# <!--
|
235
|
+
# rdoc-file=ext/bigdecimal/bigdecimal.c
|
236
|
+
# - BigDecimal.save_rounding_mode { ... }
|
237
|
+
# -->
|
238
|
+
# Execute the provided block, but preserve the rounding mode
|
239
|
+
#
|
240
|
+
# BigDecimal.save_rounding_mode do
|
241
|
+
# BigDecimal.mode(BigDecimal::ROUND_MODE, :up)
|
242
|
+
# puts BigDecimal.mode(BigDecimal::ROUND_MODE)
|
243
|
+
# end
|
244
|
+
#
|
245
|
+
# For use with the BigDecimal::ROUND_*
|
246
|
+
#
|
247
|
+
# See BigDecimal.mode
|
248
|
+
#
|
249
|
+
def self.save_rounding_mode: () { (?nil) -> void } -> void
|
250
|
+
|
251
|
+
# <!--
|
252
|
+
# rdoc-file=ext/bigdecimal/bigdecimal.c
|
253
|
+
# - a % b
|
254
|
+
# - a.modulo(b)
|
255
|
+
# -->
|
256
|
+
# Returns the modulus from dividing by b.
|
257
|
+
#
|
258
|
+
# See BigDecimal#divmod.
|
259
|
+
#
|
260
|
+
def %: (Numeric) -> BigDecimal
|
261
|
+
|
262
|
+
# <!--
|
263
|
+
# rdoc-file=ext/bigdecimal/bigdecimal.c
|
264
|
+
# - *(p1)
|
265
|
+
# -->
|
266
|
+
#
|
267
|
+
def *: (Numeric) -> BigDecimal
|
268
|
+
|
269
|
+
# <!--
|
270
|
+
# rdoc-file=ext/bigdecimal/bigdecimal.c
|
271
|
+
# - self ** other -> bigdecimal
|
272
|
+
# -->
|
273
|
+
# Returns the BigDecimal value of `self` raised to power `other`:
|
274
|
+
#
|
275
|
+
# b = BigDecimal('3.14')
|
276
|
+
# b ** 2 # => 0.98596e1
|
277
|
+
# b ** 2.0 # => 0.98596e1
|
278
|
+
# b ** Rational(2, 1) # => 0.98596e1
|
279
|
+
#
|
280
|
+
# Related: BigDecimal#power.
|
281
|
+
#
|
282
|
+
def **: (Numeric) -> BigDecimal
|
283
|
+
|
284
|
+
# <!--
|
285
|
+
# rdoc-file=ext/bigdecimal/bigdecimal.c
|
286
|
+
# - self + value -> bigdecimal
|
287
|
+
# -->
|
288
|
+
# Returns the BigDecimal sum of `self` and `value`:
|
289
|
+
#
|
290
|
+
# b = BigDecimal('111111.111') # => 0.111111111e6
|
291
|
+
# b + 2 # => 0.111113111e6
|
292
|
+
# b + 2.0 # => 0.111113111e6
|
293
|
+
# b + Rational(2, 1) # => 0.111113111e6
|
294
|
+
# b + Complex(2, 0) # => (0.111113111e6+0i)
|
295
|
+
#
|
296
|
+
# See the [Note About
|
297
|
+
# Precision](BigDecimal.html#class-BigDecimal-label-A+Note+About+Precision).
|
298
|
+
#
|
299
|
+
def +: (Numeric) -> BigDecimal
|
300
|
+
|
301
|
+
# <!--
|
302
|
+
# rdoc-file=ext/bigdecimal/bigdecimal.c
|
303
|
+
# - +big_decimal -> self
|
304
|
+
# -->
|
305
|
+
# Returns `self`:
|
306
|
+
#
|
307
|
+
# +BigDecimal(5) # => 0.5e1
|
308
|
+
# +BigDecimal(-5) # => -0.5e1
|
309
|
+
#
|
310
|
+
def +@: () -> BigDecimal
|
311
|
+
|
312
|
+
# <!--
|
313
|
+
# rdoc-file=ext/bigdecimal/bigdecimal.c
|
314
|
+
# - self - value -> bigdecimal
|
315
|
+
# -->
|
316
|
+
# Returns the BigDecimal difference of `self` and `value`:
|
317
|
+
#
|
318
|
+
# b = BigDecimal('333333.333') # => 0.333333333e6
|
319
|
+
# b - 2 # => 0.333331333e6
|
320
|
+
# b - 2.0 # => 0.333331333e6
|
321
|
+
# b - Rational(2, 1) # => 0.333331333e6
|
322
|
+
# b - Complex(2, 0) # => (0.333331333e6+0i)
|
323
|
+
#
|
324
|
+
# See the [Note About
|
325
|
+
# Precision](BigDecimal.html#class-BigDecimal-label-A+Note+About+Precision).
|
326
|
+
#
|
327
|
+
def -: (Numeric) -> BigDecimal
|
328
|
+
|
329
|
+
# <!--
|
330
|
+
# rdoc-file=ext/bigdecimal/bigdecimal.c
|
331
|
+
# - -self -> bigdecimal
|
332
|
+
# -->
|
333
|
+
# Returns the BigDecimal negation of self:
|
334
|
+
#
|
335
|
+
# b0 = BigDecimal('1.5')
|
336
|
+
# b1 = -b0 # => -0.15e1
|
337
|
+
# b2 = -b1 # => 0.15e1
|
338
|
+
#
|
339
|
+
def -@: () -> BigDecimal
|
340
|
+
|
341
|
+
# <!--
|
342
|
+
# rdoc-file=ext/bigdecimal/bigdecimal.c
|
343
|
+
# - a / b -> bigdecimal
|
344
|
+
# -->
|
345
|
+
# Divide by the specified value.
|
346
|
+
#
|
347
|
+
# The result precision will be the precision of the larger operand, but its
|
348
|
+
# minimum is 2*Float::DIG.
|
349
|
+
#
|
350
|
+
# See BigDecimal#div. See BigDecimal#quo.
|
351
|
+
#
|
352
|
+
def /: (Numeric) -> BigDecimal
|
353
|
+
|
354
|
+
# <!--
|
355
|
+
# rdoc-file=ext/bigdecimal/bigdecimal.c
|
356
|
+
# - self < other -> true or false
|
357
|
+
# -->
|
358
|
+
# Returns `true` if `self` is less than `other`, `false` otherwise:
|
359
|
+
#
|
360
|
+
# b = BigDecimal('1.5') # => 0.15e1
|
361
|
+
# b < 2 # => true
|
362
|
+
# b < 2.0 # => true
|
363
|
+
# b < Rational(2, 1) # => true
|
364
|
+
# b < 1.5 # => false
|
365
|
+
#
|
366
|
+
# Raises an exception if the comparison cannot be made.
|
367
|
+
#
|
368
|
+
def <: (Numeric) -> bool
|
369
|
+
|
370
|
+
# <!--
|
371
|
+
# rdoc-file=ext/bigdecimal/bigdecimal.c
|
372
|
+
# - self <= other -> true or false
|
373
|
+
# -->
|
374
|
+
# Returns `true` if `self` is less or equal to than `other`, `false` otherwise:
|
375
|
+
#
|
376
|
+
# b = BigDecimal('1.5') # => 0.15e1
|
377
|
+
# b <= 2 # => true
|
378
|
+
# b <= 2.0 # => true
|
379
|
+
# b <= Rational(2, 1) # => true
|
380
|
+
# b <= 1.5 # => true
|
381
|
+
# b < 1 # => false
|
382
|
+
#
|
383
|
+
# Raises an exception if the comparison cannot be made.
|
384
|
+
#
|
385
|
+
def <=: (Numeric) -> bool
|
386
|
+
|
387
|
+
# <!--
|
388
|
+
# rdoc-file=ext/bigdecimal/bigdecimal.c
|
389
|
+
# - <=>(p1)
|
390
|
+
# -->
|
391
|
+
# The comparison operator. a <=> b is 0 if a == b, 1 if a > b, -1 if a < b.
|
392
|
+
#
|
393
|
+
def <=>: (untyped) -> Integer?
|
394
|
+
|
395
|
+
# <!--
|
396
|
+
# rdoc-file=ext/bigdecimal/bigdecimal.c
|
397
|
+
# - ==(p1)
|
398
|
+
# -->
|
399
|
+
# Tests for value equality; returns true if the values are equal.
|
400
|
+
#
|
401
|
+
# The == and === operators and the eql? method have the same implementation for
|
402
|
+
# BigDecimal.
|
403
|
+
#
|
404
|
+
# Values may be coerced to perform the comparison:
|
405
|
+
#
|
406
|
+
# BigDecimal('1.0') == 1.0 #=> true
|
407
|
+
#
|
408
|
+
def ==: (untyped) -> bool
|
409
|
+
|
410
|
+
# <!-- rdoc-file=ext/bigdecimal/bigdecimal.c -->
|
411
|
+
# Tests for value equality; returns true if the values are equal.
|
412
|
+
#
|
413
|
+
# The == and === operators and the eql? method have the same implementation for
|
414
|
+
# BigDecimal.
|
415
|
+
#
|
416
|
+
# Values may be coerced to perform the comparison:
|
417
|
+
#
|
418
|
+
# BigDecimal('1.0') == 1.0 #=> true
|
419
|
+
#
|
420
|
+
def ===: (untyped) -> bool
|
421
|
+
|
422
|
+
# <!--
|
423
|
+
# rdoc-file=ext/bigdecimal/bigdecimal.c
|
424
|
+
# - self > other -> true or false
|
425
|
+
# -->
|
426
|
+
# Returns `true` if `self` is greater than `other`, `false` otherwise:
|
427
|
+
#
|
428
|
+
# b = BigDecimal('1.5')
|
429
|
+
# b > 1 # => true
|
430
|
+
# b > 1.0 # => true
|
431
|
+
# b > Rational(1, 1) # => true
|
432
|
+
# b > 2 # => false
|
433
|
+
#
|
434
|
+
# Raises an exception if the comparison cannot be made.
|
435
|
+
#
|
436
|
+
def >: (Numeric) -> bool
|
437
|
+
|
438
|
+
# <!--
|
439
|
+
# rdoc-file=ext/bigdecimal/bigdecimal.c
|
440
|
+
# - self >= other -> true or false
|
441
|
+
# -->
|
442
|
+
# Returns `true` if `self` is greater than or equal to `other`, `false`
|
443
|
+
# otherwise:
|
444
|
+
#
|
445
|
+
# b = BigDecimal('1.5')
|
446
|
+
# b >= 1 # => true
|
447
|
+
# b >= 1.0 # => true
|
448
|
+
# b >= Rational(1, 1) # => true
|
449
|
+
# b >= 1.5 # => true
|
450
|
+
# b > 2 # => false
|
451
|
+
#
|
452
|
+
# Raises an exception if the comparison cannot be made.
|
453
|
+
#
|
454
|
+
def >=: (Numeric) -> bool
|
455
|
+
|
456
|
+
# <!--
|
457
|
+
# rdoc-file=ext/bigdecimal/bigdecimal.c
|
458
|
+
# - _dump -> string
|
459
|
+
# -->
|
460
|
+
# Returns a string representing the marshalling of `self`. See module Marshal.
|
461
|
+
#
|
462
|
+
# inf = BigDecimal('Infinity') # => Infinity
|
463
|
+
# dumped = inf._dump # => "9:Infinity"
|
464
|
+
# BigDecimal._load(dumped) # => Infinity
|
465
|
+
#
|
466
|
+
def _dump: (?untyped) -> String
|
467
|
+
|
468
|
+
# <!--
|
469
|
+
# rdoc-file=ext/bigdecimal/bigdecimal.c
|
470
|
+
# - abs -> bigdecimal
|
471
|
+
# -->
|
472
|
+
# Returns the BigDecimal absolute value of `self`:
|
473
|
+
#
|
474
|
+
# BigDecimal('5').abs # => 0.5e1
|
475
|
+
# BigDecimal('-3').abs # => 0.3e1
|
476
|
+
#
|
477
|
+
def abs: () -> BigDecimal
|
478
|
+
|
479
|
+
# <!--
|
480
|
+
# rdoc-file=ext/bigdecimal/bigdecimal.c
|
481
|
+
# - add(value, ndigits) -> new_bigdecimal
|
482
|
+
# -->
|
483
|
+
# Returns the BigDecimal sum of `self` and `value` with a precision of `ndigits`
|
484
|
+
# decimal digits.
|
485
|
+
#
|
486
|
+
# When `ndigits` is less than the number of significant digits in the sum, the
|
487
|
+
# sum is rounded to that number of digits, according to the current rounding
|
488
|
+
# mode; see BigDecimal.mode.
|
489
|
+
#
|
490
|
+
# Examples:
|
491
|
+
#
|
492
|
+
# # Set the rounding mode.
|
493
|
+
# BigDecimal.mode(BigDecimal::ROUND_MODE, :half_up)
|
494
|
+
# b = BigDecimal('111111.111')
|
495
|
+
# b.add(1, 0) # => 0.111112111e6
|
496
|
+
# b.add(1, 3) # => 0.111e6
|
497
|
+
# b.add(1, 6) # => 0.111112e6
|
498
|
+
# b.add(1, 15) # => 0.111112111e6
|
499
|
+
# b.add(1.0, 15) # => 0.111112111e6
|
500
|
+
# b.add(Rational(1, 1), 15) # => 0.111112111e6
|
501
|
+
#
|
502
|
+
def add: (Numeric value, Integer digits) -> BigDecimal
|
503
|
+
|
504
|
+
# <!--
|
505
|
+
# rdoc-file=ext/bigdecimal/bigdecimal.c
|
506
|
+
# - ceil(n)
|
507
|
+
# -->
|
508
|
+
# Return the smallest integer greater than or equal to the value, as a
|
509
|
+
# BigDecimal.
|
510
|
+
#
|
511
|
+
# BigDecimal('3.14159').ceil #=> 4
|
512
|
+
# BigDecimal('-9.1').ceil #=> -9
|
513
|
+
#
|
514
|
+
# If n is specified and positive, the fractional part of the result has no more
|
515
|
+
# than that many digits.
|
516
|
+
#
|
517
|
+
# If n is specified and negative, at least that many digits to the left of the
|
518
|
+
# decimal point will be 0 in the result.
|
519
|
+
#
|
520
|
+
# BigDecimal('3.14159').ceil(3) #=> 3.142
|
521
|
+
# BigDecimal('13345.234').ceil(-2) #=> 13400.0
|
522
|
+
#
|
523
|
+
def ceil: () -> Integer
|
524
|
+
| (int n) -> BigDecimal
|
525
|
+
|
526
|
+
# <!--
|
527
|
+
# rdoc-file=ext/bigdecimal/bigdecimal.c
|
528
|
+
# - clone()
|
529
|
+
# -->
|
530
|
+
#
|
531
|
+
def clone: () -> self
|
532
|
+
|
533
|
+
# <!--
|
534
|
+
# rdoc-file=ext/bigdecimal/bigdecimal.c
|
535
|
+
# - coerce(p1)
|
536
|
+
# -->
|
537
|
+
# The coerce method provides support for Ruby type coercion. It is not enabled
|
538
|
+
# by default.
|
539
|
+
#
|
540
|
+
# This means that binary operations like + * / or - can often be performed on a
|
541
|
+
# BigDecimal and an object of another type, if the other object can be coerced
|
542
|
+
# into a BigDecimal value.
|
543
|
+
#
|
544
|
+
# e.g.
|
545
|
+
# a = BigDecimal("1.0")
|
546
|
+
# b = a / 2.0 #=> 0.5
|
547
|
+
#
|
548
|
+
# Note that coercing a String to a BigDecimal is not supported by default; it
|
549
|
+
# requires a special compile-time option when building Ruby.
|
550
|
+
#
|
551
|
+
def coerce: (Numeric) -> [ BigDecimal, BigDecimal ]
|
552
|
+
|
553
|
+
# <!--
|
554
|
+
# rdoc-file=ext/bigdecimal/bigdecimal.c
|
555
|
+
# - div(value) -> integer
|
556
|
+
# - div(value, digits) -> bigdecimal or integer
|
557
|
+
# -->
|
558
|
+
# Divide by the specified value.
|
559
|
+
#
|
560
|
+
# digits
|
561
|
+
# : If specified and less than the number of significant digits of the result,
|
562
|
+
# the result is rounded to that number of digits, according to
|
563
|
+
# BigDecimal.mode.
|
564
|
+
#
|
565
|
+
# If digits is 0, the result is the same as for the / operator or #quo.
|
566
|
+
#
|
567
|
+
# If digits is not specified, the result is an integer, by analogy with
|
568
|
+
# Float#div; see also BigDecimal#divmod.
|
569
|
+
#
|
570
|
+
#
|
571
|
+
# See BigDecimal#/. See BigDecimal#quo.
|
572
|
+
#
|
573
|
+
# Examples:
|
574
|
+
#
|
575
|
+
# a = BigDecimal("4")
|
576
|
+
# b = BigDecimal("3")
|
577
|
+
#
|
578
|
+
# a.div(b, 3) # => 0.133e1
|
579
|
+
#
|
580
|
+
# a.div(b, 0) # => 0.1333333333333333333e1
|
581
|
+
# a / b # => 0.1333333333333333333e1
|
582
|
+
# a.quo(b) # => 0.1333333333333333333e1
|
583
|
+
#
|
584
|
+
# a.div(b) # => 1
|
585
|
+
#
|
586
|
+
def div: (Numeric value) -> Integer
|
587
|
+
| (Numeric value, int digits) -> BigDecimal
|
588
|
+
|
589
|
+
# <!--
|
590
|
+
# rdoc-file=ext/bigdecimal/bigdecimal.c
|
591
|
+
# - divmod(value)
|
592
|
+
# -->
|
593
|
+
# Divides by the specified value, and returns the quotient and modulus as
|
594
|
+
# BigDecimal numbers. The quotient is rounded towards negative infinity.
|
595
|
+
#
|
596
|
+
# For example:
|
597
|
+
#
|
598
|
+
# require 'bigdecimal'
|
599
|
+
#
|
600
|
+
# a = BigDecimal("42")
|
601
|
+
# b = BigDecimal("9")
|
602
|
+
#
|
603
|
+
# q, m = a.divmod(b)
|
604
|
+
#
|
605
|
+
# c = q * b + m
|
606
|
+
#
|
607
|
+
# a == c #=> true
|
608
|
+
#
|
609
|
+
# The quotient q is (a/b).floor, and the modulus is the amount that must be
|
610
|
+
# added to q * b to get a.
|
611
|
+
#
|
612
|
+
def divmod: (Numeric) -> [ BigDecimal, BigDecimal ]
|
613
|
+
|
614
|
+
# <!--
|
615
|
+
# rdoc-file=ext/bigdecimal/bigdecimal.c
|
616
|
+
# - dup()
|
617
|
+
# -->
|
618
|
+
#
|
619
|
+
def dup: () -> self
|
620
|
+
|
621
|
+
# <!-- rdoc-file=ext/bigdecimal/bigdecimal.c -->
|
622
|
+
# Tests for value equality; returns true if the values are equal.
|
623
|
+
#
|
624
|
+
# The == and === operators and the eql? method have the same implementation for
|
625
|
+
# BigDecimal.
|
626
|
+
#
|
627
|
+
# Values may be coerced to perform the comparison:
|
628
|
+
#
|
629
|
+
# BigDecimal('1.0') == 1.0 #=> true
|
630
|
+
#
|
631
|
+
def eql?: (untyped) -> bool
|
632
|
+
|
633
|
+
# <!--
|
634
|
+
# rdoc-file=ext/bigdecimal/bigdecimal.c
|
635
|
+
# - exponent()
|
636
|
+
# -->
|
637
|
+
# Returns the exponent of the BigDecimal number, as an Integer.
|
638
|
+
#
|
639
|
+
# If the number can be represented as 0.xxxxxx*10**n where xxxxxx is a string of
|
640
|
+
# digits with no leading zeros, then n is the exponent.
|
641
|
+
#
|
642
|
+
def exponent: () -> Integer
|
643
|
+
|
644
|
+
# <!--
|
645
|
+
# rdoc-file=ext/bigdecimal/bigdecimal.c
|
646
|
+
# - finite?()
|
647
|
+
# -->
|
648
|
+
# Returns True if the value is finite (not NaN or infinite).
|
649
|
+
#
|
650
|
+
def finite?: () -> bool
|
651
|
+
|
652
|
+
# <!--
|
653
|
+
# rdoc-file=ext/bigdecimal/bigdecimal.c
|
654
|
+
# - fix()
|
655
|
+
# -->
|
656
|
+
# Return the integer part of the number, as a BigDecimal.
|
657
|
+
#
|
658
|
+
def fix: () -> BigDecimal
|
659
|
+
|
660
|
+
# <!--
|
661
|
+
# rdoc-file=ext/bigdecimal/bigdecimal.c
|
662
|
+
# - floor(n)
|
663
|
+
# -->
|
664
|
+
# Return the largest integer less than or equal to the value, as a BigDecimal.
|
665
|
+
#
|
666
|
+
# BigDecimal('3.14159').floor #=> 3
|
667
|
+
# BigDecimal('-9.1').floor #=> -10
|
668
|
+
#
|
669
|
+
# If n is specified and positive, the fractional part of the result has no more
|
670
|
+
# than that many digits.
|
671
|
+
#
|
672
|
+
# If n is specified and negative, at least that many digits to the left of the
|
673
|
+
# decimal point will be 0 in the result.
|
674
|
+
#
|
675
|
+
# BigDecimal('3.14159').floor(3) #=> 3.141
|
676
|
+
# BigDecimal('13345.234').floor(-2) #=> 13300.0
|
677
|
+
#
|
678
|
+
def floor: () -> Integer
|
679
|
+
| (int n) -> BigDecimal
|
680
|
+
|
681
|
+
# <!--
|
682
|
+
# rdoc-file=ext/bigdecimal/bigdecimal.c
|
683
|
+
# - frac()
|
684
|
+
# -->
|
685
|
+
# Return the fractional part of the number, as a BigDecimal.
|
686
|
+
#
|
687
|
+
def frac: () -> BigDecimal
|
688
|
+
|
689
|
+
# <!--
|
690
|
+
# rdoc-file=ext/bigdecimal/bigdecimal.c
|
691
|
+
# - hash -> integer
|
692
|
+
# -->
|
693
|
+
# Returns the integer hash value for `self`.
|
694
|
+
#
|
695
|
+
# Two instances of BigDecimal have the same hash value if and only if they have
|
696
|
+
# equal:
|
697
|
+
#
|
698
|
+
# * Sign.
|
699
|
+
# * Fractional part.
|
700
|
+
# * Exponent.
|
701
|
+
#
|
702
|
+
def hash: () -> Integer
|
703
|
+
|
704
|
+
# <!--
|
705
|
+
# rdoc-file=ext/bigdecimal/bigdecimal.c
|
706
|
+
# - infinite?()
|
707
|
+
# -->
|
708
|
+
# Returns nil, -1, or +1 depending on whether the value is finite, -Infinity, or
|
709
|
+
# +Infinity.
|
710
|
+
#
|
711
|
+
def infinite?: () -> Integer?
|
712
|
+
|
713
|
+
# <!--
|
714
|
+
# rdoc-file=ext/bigdecimal/bigdecimal.c
|
715
|
+
# - inspect()
|
716
|
+
# -->
|
717
|
+
# Returns a string representation of self.
|
718
|
+
#
|
719
|
+
# BigDecimal("1234.5678").inspect
|
720
|
+
# #=> "0.12345678e4"
|
721
|
+
#
|
722
|
+
def inspect: () -> String
|
723
|
+
|
724
|
+
# <!-- rdoc-file=ext/bigdecimal/bigdecimal.c -->
|
725
|
+
# Returns the modulus from dividing by b.
|
726
|
+
#
|
727
|
+
# See BigDecimal#divmod.
|
728
|
+
#
|
729
|
+
def modulo: (Numeric b) -> BigDecimal
|
730
|
+
|
731
|
+
# <!--
|
732
|
+
# rdoc-file=ext/bigdecimal/bigdecimal.c
|
733
|
+
# - mult(other, ndigits) -> bigdecimal
|
734
|
+
# -->
|
735
|
+
# Returns the BigDecimal product of `self` and `value` with a precision of
|
736
|
+
# `ndigits` decimal digits.
|
737
|
+
#
|
738
|
+
# When `ndigits` is less than the number of significant digits in the sum, the
|
739
|
+
# sum is rounded to that number of digits, according to the current rounding
|
740
|
+
# mode; see BigDecimal.mode.
|
741
|
+
#
|
742
|
+
# Examples:
|
743
|
+
#
|
744
|
+
# # Set the rounding mode.
|
745
|
+
# BigDecimal.mode(BigDecimal::ROUND_MODE, :half_up)
|
746
|
+
# b = BigDecimal('555555.555')
|
747
|
+
# b.mult(3, 0) # => 0.1666666665e7
|
748
|
+
# b.mult(3, 3) # => 0.167e7
|
749
|
+
# b.mult(3, 6) # => 0.166667e7
|
750
|
+
# b.mult(3, 15) # => 0.1666666665e7
|
751
|
+
# b.mult(3.0, 0) # => 0.1666666665e7
|
752
|
+
# b.mult(Rational(3, 1), 0) # => 0.1666666665e7
|
753
|
+
# b.mult(Complex(3, 0), 0) # => (0.1666666665e7+0.0i)
|
754
|
+
#
|
755
|
+
def mult: (Numeric value, int digits) -> BigDecimal
|
756
|
+
|
757
|
+
# <!--
|
758
|
+
# rdoc-file=ext/bigdecimal/bigdecimal.c
|
759
|
+
# - nan?()
|
760
|
+
# -->
|
761
|
+
# Returns True if the value is Not a Number.
|
762
|
+
#
|
763
|
+
def nan?: () -> bool
|
764
|
+
|
765
|
+
# <!--
|
766
|
+
# rdoc-file=ext/bigdecimal/bigdecimal.c
|
767
|
+
# - nonzero?()
|
768
|
+
# -->
|
769
|
+
# Returns self if the value is non-zero, nil otherwise.
|
770
|
+
#
|
771
|
+
def nonzero?: () -> self?
|
772
|
+
|
773
|
+
# <!--
|
774
|
+
# rdoc-file=ext/bigdecimal/bigdecimal.c
|
775
|
+
# - power(n)
|
776
|
+
# - power(n, prec)
|
777
|
+
# -->
|
778
|
+
# Returns the value raised to the power of n.
|
779
|
+
#
|
780
|
+
# Note that n must be an Integer.
|
781
|
+
#
|
782
|
+
# Also available as the operator **.
|
783
|
+
#
|
784
|
+
def power: (Numeric n, int prec) -> BigDecimal
|
785
|
+
|
786
|
+
# <!--
|
787
|
+
# rdoc-file=ext/bigdecimal/bigdecimal.c
|
788
|
+
# - precs -> array
|
789
|
+
# -->
|
790
|
+
# Returns an Array of two Integer values that represent platform-dependent
|
791
|
+
# internal storage properties.
|
792
|
+
#
|
793
|
+
# This method is deprecated and will be removed in the future. Instead, use
|
794
|
+
# BigDecimal#n_significant_digits for obtaining the number of significant digits
|
795
|
+
# in scientific notation, and BigDecimal#precision for obtaining the number of
|
796
|
+
# digits in decimal notation.
|
797
|
+
#
|
798
|
+
def precs: () -> [ Integer, Integer ]
|
799
|
+
|
800
|
+
# <!--
|
801
|
+
# rdoc-file=ext/bigdecimal/bigdecimal.c
|
802
|
+
# - quo(value) -> bigdecimal
|
803
|
+
# - quo(value, digits) -> bigdecimal
|
804
|
+
# -->
|
805
|
+
# Divide by the specified value.
|
806
|
+
#
|
807
|
+
# digits
|
808
|
+
# : If specified and less than the number of significant digits of the result,
|
809
|
+
# the result is rounded to the given number of digits, according to the
|
810
|
+
# rounding mode indicated by BigDecimal.mode.
|
811
|
+
#
|
812
|
+
# If digits is 0 or omitted, the result is the same as for the / operator.
|
813
|
+
#
|
814
|
+
#
|
815
|
+
# See BigDecimal#/. See BigDecimal#div.
|
816
|
+
#
|
817
|
+
def quo: (Numeric) -> BigDecimal
|
818
|
+
|
819
|
+
# <!--
|
820
|
+
# rdoc-file=ext/bigdecimal/bigdecimal.c
|
821
|
+
# - remainder(value)
|
822
|
+
# -->
|
823
|
+
# Returns the remainder from dividing by the value.
|
824
|
+
#
|
825
|
+
# x.remainder(y) means x-y*(x/y).truncate
|
826
|
+
#
|
827
|
+
def remainder: (Numeric) -> BigDecimal
|
828
|
+
|
829
|
+
# <!--
|
830
|
+
# rdoc-file=ext/bigdecimal/bigdecimal.c
|
831
|
+
# - round(n, mode)
|
832
|
+
# -->
|
833
|
+
# Round to the nearest integer (by default), returning the result as a
|
834
|
+
# BigDecimal if n is specified, or as an Integer if it isn't.
|
835
|
+
#
|
836
|
+
# BigDecimal('3.14159').round #=> 3
|
837
|
+
# BigDecimal('8.7').round #=> 9
|
838
|
+
# BigDecimal('-9.9').round #=> -10
|
839
|
+
#
|
840
|
+
# BigDecimal('3.14159').round(2).class.name #=> "BigDecimal"
|
841
|
+
# BigDecimal('3.14159').round.class.name #=> "Integer"
|
842
|
+
#
|
843
|
+
# If n is specified and positive, the fractional part of the result has no more
|
844
|
+
# than that many digits.
|
845
|
+
#
|
846
|
+
# If n is specified and negative, at least that many digits to the left of the
|
847
|
+
# decimal point will be 0 in the result, and return value will be an Integer.
|
848
|
+
#
|
849
|
+
# BigDecimal('3.14159').round(3) #=> 3.142
|
850
|
+
# BigDecimal('13345.234').round(-2) #=> 13300
|
851
|
+
#
|
852
|
+
# The value of the optional mode argument can be used to determine how rounding
|
853
|
+
# is performed; see BigDecimal.mode.
|
854
|
+
#
|
855
|
+
def round: () -> Integer
|
856
|
+
| (Numeric n, ?Integer mode) -> BigDecimal
|
857
|
+
|
858
|
+
# <!--
|
859
|
+
# rdoc-file=ext/bigdecimal/bigdecimal.c
|
860
|
+
# - sign()
|
861
|
+
# -->
|
862
|
+
# Returns the sign of the value.
|
863
|
+
#
|
864
|
+
# Returns a positive value if > 0, a negative value if < 0. It behaves the same
|
865
|
+
# with zeros - it returns a positive value for a positive zero (BigDecimal('0'))
|
866
|
+
# and a negative value for a negative zero (BigDecimal('-0')).
|
867
|
+
#
|
868
|
+
# The specific value returned indicates the type and sign of the BigDecimal, as
|
869
|
+
# follows:
|
870
|
+
#
|
871
|
+
# BigDecimal::SIGN_NaN
|
872
|
+
# : value is Not a Number
|
873
|
+
#
|
874
|
+
# BigDecimal::SIGN_POSITIVE_ZERO
|
875
|
+
# : value is +0
|
876
|
+
#
|
877
|
+
# BigDecimal::SIGN_NEGATIVE_ZERO
|
878
|
+
# : value is -0
|
879
|
+
#
|
880
|
+
# BigDecimal::SIGN_POSITIVE_INFINITE
|
881
|
+
# : value is +Infinity
|
882
|
+
#
|
883
|
+
# BigDecimal::SIGN_NEGATIVE_INFINITE
|
884
|
+
# : value is -Infinity
|
885
|
+
#
|
886
|
+
# BigDecimal::SIGN_POSITIVE_FINITE
|
887
|
+
# : value is positive
|
888
|
+
#
|
889
|
+
# BigDecimal::SIGN_NEGATIVE_FINITE
|
890
|
+
# : value is negative
|
891
|
+
#
|
892
|
+
def sign: () -> Integer
|
893
|
+
|
894
|
+
# <!--
|
895
|
+
# rdoc-file=ext/bigdecimal/bigdecimal.c
|
896
|
+
# - split()
|
897
|
+
# -->
|
898
|
+
# Splits a BigDecimal number into four parts, returned as an array of values.
|
899
|
+
#
|
900
|
+
# The first value represents the sign of the BigDecimal, and is -1 or 1, or 0 if
|
901
|
+
# the BigDecimal is Not a Number.
|
902
|
+
#
|
903
|
+
# The second value is a string representing the significant digits of the
|
904
|
+
# BigDecimal, with no leading zeros.
|
905
|
+
#
|
906
|
+
# The third value is the base used for arithmetic (currently always 10) as an
|
907
|
+
# Integer.
|
908
|
+
#
|
909
|
+
# The fourth value is an Integer exponent.
|
910
|
+
#
|
911
|
+
# If the BigDecimal can be represented as 0.xxxxxx*10**n, then xxxxxx is the
|
912
|
+
# string of significant digits with no leading zeros, and n is the exponent.
|
913
|
+
#
|
914
|
+
# From these values, you can translate a BigDecimal to a float as follows:
|
915
|
+
#
|
916
|
+
# sign, significant_digits, base, exponent = a.split
|
917
|
+
# f = sign * "0.#{significant_digits}".to_f * (base ** exponent)
|
918
|
+
#
|
919
|
+
# (Note that the to_f method is provided as a more convenient way to translate a
|
920
|
+
# BigDecimal to a Float.)
|
921
|
+
#
|
922
|
+
def split: () -> [ Integer, String, Integer, Integer ]
|
923
|
+
|
924
|
+
# <!--
|
925
|
+
# rdoc-file=ext/bigdecimal/bigdecimal.c
|
926
|
+
# - sqrt(n)
|
927
|
+
# -->
|
928
|
+
# Returns the square root of the value.
|
929
|
+
#
|
930
|
+
# Result has at least n significant digits.
|
931
|
+
#
|
932
|
+
def sqrt: (int n) -> BigDecimal
|
933
|
+
|
934
|
+
# <!--
|
935
|
+
# rdoc-file=ext/bigdecimal/bigdecimal.c
|
936
|
+
# - sub(value, digits) -> bigdecimal
|
937
|
+
# -->
|
938
|
+
# Subtract the specified value.
|
939
|
+
#
|
940
|
+
# e.g.
|
941
|
+
# c = a.sub(b,n)
|
942
|
+
#
|
943
|
+
# digits
|
944
|
+
# : If specified and less than the number of significant digits of the result,
|
945
|
+
# the result is rounded to that number of digits, according to
|
946
|
+
# BigDecimal.mode.
|
947
|
+
#
|
948
|
+
def sub: (Numeric value, int digits) -> BigDecimal
|
949
|
+
|
950
|
+
# <!--
|
951
|
+
# rdoc-file=ext/bigdecimal/bigdecimal.c
|
952
|
+
# - to_f()
|
953
|
+
# -->
|
954
|
+
# Returns a new Float object having approximately the same value as the
|
955
|
+
# BigDecimal number. Normal accuracy limits and built-in errors of binary Float
|
956
|
+
# arithmetic apply.
|
957
|
+
#
|
958
|
+
def to_f: () -> Float
|
959
|
+
|
960
|
+
# <!--
|
961
|
+
# rdoc-file=ext/bigdecimal/bigdecimal.c
|
962
|
+
# - to_i()
|
963
|
+
# -->
|
964
|
+
# Returns the value as an Integer.
|
965
|
+
#
|
966
|
+
# If the BigDecimal is infinity or NaN, raises FloatDomainError.
|
967
|
+
#
|
968
|
+
def to_i: () -> Integer
|
969
|
+
|
970
|
+
# <!-- rdoc-file=ext/bigdecimal/bigdecimal.c -->
|
971
|
+
# Returns the value as an Integer.
|
972
|
+
#
|
973
|
+
# If the BigDecimal is infinity or NaN, raises FloatDomainError.
|
974
|
+
#
|
975
|
+
def to_int: () -> Integer
|
976
|
+
|
977
|
+
# <!--
|
978
|
+
# rdoc-file=ext/bigdecimal/bigdecimal.c
|
979
|
+
# - to_r()
|
980
|
+
# -->
|
981
|
+
# Converts a BigDecimal to a Rational.
|
982
|
+
#
|
983
|
+
def to_r: () -> Rational
|
984
|
+
|
985
|
+
# <!--
|
986
|
+
# rdoc-file=ext/bigdecimal/bigdecimal.c
|
987
|
+
# - to_s(s)
|
988
|
+
# -->
|
989
|
+
# Converts the value to a string.
|
990
|
+
#
|
991
|
+
# The default format looks like 0.xxxxEnn.
|
992
|
+
#
|
993
|
+
# The optional parameter s consists of either an integer; or an optional '+' or
|
994
|
+
# ' ', followed by an optional number, followed by an optional 'E' or 'F'.
|
995
|
+
#
|
996
|
+
# If there is a '+' at the start of s, positive values are returned with a
|
997
|
+
# leading '+'.
|
998
|
+
#
|
999
|
+
# A space at the start of s returns positive values with a leading space.
|
1000
|
+
#
|
1001
|
+
# If s contains a number, a space is inserted after each group of that many
|
1002
|
+
# digits, starting from '.' and counting outwards.
|
1003
|
+
#
|
1004
|
+
# If s ends with an 'E', engineering notation (0.xxxxEnn) is used.
|
1005
|
+
#
|
1006
|
+
# If s ends with an 'F', conventional floating point notation is used.
|
1007
|
+
#
|
1008
|
+
# Examples:
|
1009
|
+
#
|
1010
|
+
# BigDecimal('-1234567890123.45678901234567890').to_s('5F')
|
1011
|
+
# #=> '-123 45678 90123.45678 90123 45678 9'
|
1012
|
+
#
|
1013
|
+
# BigDecimal('1234567890123.45678901234567890').to_s('+8F')
|
1014
|
+
# #=> '+12345 67890123.45678901 23456789'
|
1015
|
+
#
|
1016
|
+
# BigDecimal('1234567890123.45678901234567890').to_s(' F')
|
1017
|
+
# #=> ' 1234567890123.4567890123456789'
|
1018
|
+
#
|
1019
|
+
def to_s: (?String | int s) -> String
|
1020
|
+
|
1021
|
+
# <!--
|
1022
|
+
# rdoc-file=ext/bigdecimal/bigdecimal.c
|
1023
|
+
# - truncate(n)
|
1024
|
+
# -->
|
1025
|
+
# Truncate to the nearest integer (by default), returning the result as a
|
1026
|
+
# BigDecimal.
|
1027
|
+
#
|
1028
|
+
# BigDecimal('3.14159').truncate #=> 3
|
1029
|
+
# BigDecimal('8.7').truncate #=> 8
|
1030
|
+
# BigDecimal('-9.9').truncate #=> -9
|
1031
|
+
#
|
1032
|
+
# If n is specified and positive, the fractional part of the result has no more
|
1033
|
+
# than that many digits.
|
1034
|
+
#
|
1035
|
+
# If n is specified and negative, at least that many digits to the left of the
|
1036
|
+
# decimal point will be 0 in the result.
|
1037
|
+
#
|
1038
|
+
# BigDecimal('3.14159').truncate(3) #=> 3.141
|
1039
|
+
# BigDecimal('13345.234').truncate(-2) #=> 13300.0
|
1040
|
+
#
|
1041
|
+
def truncate: () -> Integer
|
1042
|
+
| (int n) -> BigDecimal
|
1043
|
+
|
1044
|
+
# <!--
|
1045
|
+
# rdoc-file=ext/bigdecimal/bigdecimal.c
|
1046
|
+
# - zero?()
|
1047
|
+
# -->
|
1048
|
+
# Returns True if the value is zero.
|
1049
|
+
#
|
1050
|
+
def zero?: () -> bool
|
1051
|
+
|
1052
|
+
# <!--
|
1053
|
+
# rdoc-file=ext/bigdecimal/lib/bigdecimal/util.rb
|
1054
|
+
# - a.to_d -> bigdecimal
|
1055
|
+
# -->
|
1056
|
+
# Returns self.
|
1057
|
+
#
|
1058
|
+
# require 'bigdecimal/util'
|
1059
|
+
#
|
1060
|
+
# d = BigDecimal("3.14")
|
1061
|
+
# d.to_d # => 0.314e1
|
1062
|
+
#
|
1063
|
+
def to_d: () -> BigDecimal
|
1064
|
+
|
1065
|
+
private
|
1066
|
+
|
1067
|
+
def initialize_copy: (self) -> self
|
1068
|
+
end
|
1069
|
+
|
1070
|
+
# <!-- rdoc-file=ext/bigdecimal/bigdecimal.c -->
|
1071
|
+
# Base value used in internal calculations. On a 32 bit system, BASE is 10000,
|
1072
|
+
# indicating that calculation is done in groups of 4 digits. (If it were larger,
|
1073
|
+
# BASE**2 wouldn't fit in 32 bits, so you couldn't guarantee that two groups
|
1074
|
+
# could always be multiplied together without overflow.)
|
1075
|
+
#
|
1076
|
+
BigDecimal::BASE: Integer
|
1077
|
+
|
1078
|
+
# <!-- rdoc-file=ext/bigdecimal/bigdecimal.c -->
|
1079
|
+
# Determines whether overflow, underflow or zero divide result in an exception
|
1080
|
+
# being thrown. See BigDecimal.mode.
|
1081
|
+
#
|
1082
|
+
BigDecimal::EXCEPTION_ALL: Integer
|
1083
|
+
|
1084
|
+
# <!-- rdoc-file=ext/bigdecimal/bigdecimal.c -->
|
1085
|
+
# Determines what happens when the result of a computation is infinity. See
|
1086
|
+
# BigDecimal.mode.
|
1087
|
+
#
|
1088
|
+
BigDecimal::EXCEPTION_INFINITY: Integer
|
1089
|
+
|
1090
|
+
# <!-- rdoc-file=ext/bigdecimal/bigdecimal.c -->
|
1091
|
+
# Determines what happens when the result of a computation is not a number
|
1092
|
+
# (NaN). See BigDecimal.mode.
|
1093
|
+
#
|
1094
|
+
BigDecimal::EXCEPTION_NaN: Integer
|
1095
|
+
|
1096
|
+
# <!-- rdoc-file=ext/bigdecimal/bigdecimal.c -->
|
1097
|
+
# Determines what happens when the result of a computation is an overflow (a
|
1098
|
+
# result too large to be represented). See BigDecimal.mode.
|
1099
|
+
#
|
1100
|
+
BigDecimal::EXCEPTION_OVERFLOW: Integer
|
1101
|
+
|
1102
|
+
# <!-- rdoc-file=ext/bigdecimal/bigdecimal.c -->
|
1103
|
+
# Determines what happens when the result of a computation is an underflow (a
|
1104
|
+
# result too small to be represented). See BigDecimal.mode.
|
1105
|
+
#
|
1106
|
+
BigDecimal::EXCEPTION_UNDERFLOW: Integer
|
1107
|
+
|
1108
|
+
# <!-- rdoc-file=ext/bigdecimal/bigdecimal.c -->
|
1109
|
+
# Determines what happens when a division by zero is performed. See
|
1110
|
+
# BigDecimal.mode.
|
1111
|
+
#
|
1112
|
+
BigDecimal::EXCEPTION_ZERODIVIDE: Integer
|
1113
|
+
|
1114
|
+
# <!-- rdoc-file=ext/bigdecimal/bigdecimal.c -->
|
1115
|
+
# Special value constants
|
1116
|
+
#
|
1117
|
+
BigDecimal::INFINITY: BigDecimal
|
1118
|
+
|
1119
|
+
BigDecimal::NAN: BigDecimal
|
1120
|
+
|
1121
|
+
# <!-- rdoc-file=ext/bigdecimal/bigdecimal.c -->
|
1122
|
+
# Round towards +Infinity. See BigDecimal.mode.
|
1123
|
+
#
|
1124
|
+
BigDecimal::ROUND_CEILING: Integer
|
1125
|
+
|
1126
|
+
# <!-- rdoc-file=ext/bigdecimal/bigdecimal.c -->
|
1127
|
+
# Indicates that values should be rounded towards zero. See BigDecimal.mode.
|
1128
|
+
#
|
1129
|
+
BigDecimal::ROUND_DOWN: Integer
|
1130
|
+
|
1131
|
+
# <!-- rdoc-file=ext/bigdecimal/bigdecimal.c -->
|
1132
|
+
# Round towards -Infinity. See BigDecimal.mode.
|
1133
|
+
#
|
1134
|
+
BigDecimal::ROUND_FLOOR: Integer
|
1135
|
+
|
1136
|
+
# <!-- rdoc-file=ext/bigdecimal/bigdecimal.c -->
|
1137
|
+
# Indicates that digits >= 6 should be rounded up, others rounded down. See
|
1138
|
+
# BigDecimal.mode.
|
1139
|
+
#
|
1140
|
+
BigDecimal::ROUND_HALF_DOWN: Integer
|
1141
|
+
|
1142
|
+
# <!-- rdoc-file=ext/bigdecimal/bigdecimal.c -->
|
1143
|
+
# Round towards the even neighbor. See BigDecimal.mode.
|
1144
|
+
#
|
1145
|
+
BigDecimal::ROUND_HALF_EVEN: Integer
|
1146
|
+
|
1147
|
+
# <!-- rdoc-file=ext/bigdecimal/bigdecimal.c -->
|
1148
|
+
# Indicates that digits >= 5 should be rounded up, others rounded down. See
|
1149
|
+
# BigDecimal.mode.
|
1150
|
+
#
|
1151
|
+
BigDecimal::ROUND_HALF_UP: Integer
|
1152
|
+
|
1153
|
+
# <!-- rdoc-file=ext/bigdecimal/bigdecimal.c -->
|
1154
|
+
# Determines what happens when a result must be rounded in order to fit in the
|
1155
|
+
# appropriate number of significant digits. See BigDecimal.mode.
|
1156
|
+
#
|
1157
|
+
BigDecimal::ROUND_MODE: Integer
|
1158
|
+
|
1159
|
+
# <!-- rdoc-file=ext/bigdecimal/bigdecimal.c -->
|
1160
|
+
# Indicates that values should be rounded away from zero. See BigDecimal.mode.
|
1161
|
+
#
|
1162
|
+
BigDecimal::ROUND_UP: Integer
|
1163
|
+
|
1164
|
+
# <!-- rdoc-file=ext/bigdecimal/bigdecimal.c -->
|
1165
|
+
# Indicates that a value is negative and finite. See BigDecimal.sign.
|
1166
|
+
#
|
1167
|
+
BigDecimal::SIGN_NEGATIVE_FINITE: Integer
|
1168
|
+
|
1169
|
+
# <!-- rdoc-file=ext/bigdecimal/bigdecimal.c -->
|
1170
|
+
# Indicates that a value is negative and infinite. See BigDecimal.sign.
|
1171
|
+
#
|
1172
|
+
BigDecimal::SIGN_NEGATIVE_INFINITE: Integer
|
1173
|
+
|
1174
|
+
# <!-- rdoc-file=ext/bigdecimal/bigdecimal.c -->
|
1175
|
+
# Indicates that a value is -0. See BigDecimal.sign.
|
1176
|
+
#
|
1177
|
+
BigDecimal::SIGN_NEGATIVE_ZERO: Integer
|
1178
|
+
|
1179
|
+
# <!-- rdoc-file=ext/bigdecimal/bigdecimal.c -->
|
1180
|
+
# Indicates that a value is not a number. See BigDecimal.sign.
|
1181
|
+
#
|
1182
|
+
BigDecimal::SIGN_NaN: Integer
|
1183
|
+
|
1184
|
+
# <!-- rdoc-file=ext/bigdecimal/bigdecimal.c -->
|
1185
|
+
# Indicates that a value is positive and finite. See BigDecimal.sign.
|
1186
|
+
#
|
1187
|
+
BigDecimal::SIGN_POSITIVE_FINITE: Integer
|
1188
|
+
|
1189
|
+
# <!-- rdoc-file=ext/bigdecimal/bigdecimal.c -->
|
1190
|
+
# Indicates that a value is positive and infinite. See BigDecimal.sign.
|
1191
|
+
#
|
1192
|
+
BigDecimal::SIGN_POSITIVE_INFINITE: Integer
|
1193
|
+
|
1194
|
+
# <!-- rdoc-file=ext/bigdecimal/bigdecimal.c -->
|
1195
|
+
# Indicates that a value is +0. See BigDecimal.sign.
|
1196
|
+
#
|
1197
|
+
BigDecimal::SIGN_POSITIVE_ZERO: Integer
|
1198
|
+
|
1199
|
+
# <!-- rdoc-file=ext/bigdecimal/bigdecimal.c -->
|
1200
|
+
# The version of bigdecimal library
|
1201
|
+
#
|
1202
|
+
BigDecimal::VERSION: String
|
1203
|
+
|
1204
|
+
%a{annotate:rdoc:skip}
|
1205
|
+
module Kernel
|
1206
|
+
private
|
1207
|
+
|
1208
|
+
# <!--
|
1209
|
+
# rdoc-file=ext/bigdecimal/bigdecimal.c
|
1210
|
+
# - BigDecimal(value, exception: true) -> bigdecimal
|
1211
|
+
# - BigDecimal(value, ndigits, exception: true) -> bigdecimal
|
1212
|
+
# -->
|
1213
|
+
# Returns the BigDecimal converted from `value` with a precision of `ndigits`
|
1214
|
+
# decimal digits.
|
1215
|
+
#
|
1216
|
+
# When `ndigits` is less than the number of significant digits in the value, the
|
1217
|
+
# result is rounded to that number of digits, according to the current rounding
|
1218
|
+
# mode; see BigDecimal.mode.
|
1219
|
+
#
|
1220
|
+
# When `ndigits` is 0, the number of digits to correctly represent a float
|
1221
|
+
# number is determined automatically.
|
1222
|
+
#
|
1223
|
+
# Returns `value` converted to a BigDecimal, depending on the type of `value`:
|
1224
|
+
#
|
1225
|
+
# * Integer, Float, Rational, Complex, or BigDecimal: converted directly:
|
1226
|
+
#
|
1227
|
+
# # Integer, Complex, or BigDecimal value does not require ndigits; ignored if given.
|
1228
|
+
# BigDecimal(2) # => 0.2e1
|
1229
|
+
# BigDecimal(Complex(2, 0)) # => 0.2e1
|
1230
|
+
# BigDecimal(BigDecimal(2)) # => 0.2e1
|
1231
|
+
# # Float or Rational value requires ndigits.
|
1232
|
+
# BigDecimal(2.0, 0) # => 0.2e1
|
1233
|
+
# BigDecimal(Rational(2, 1), 0) # => 0.2e1
|
1234
|
+
#
|
1235
|
+
# * String: converted by parsing if it contains an integer or floating-point
|
1236
|
+
# literal; leading and trailing whitespace is ignored:
|
1237
|
+
#
|
1238
|
+
# # String does not require ndigits; ignored if given.
|
1239
|
+
# BigDecimal('2') # => 0.2e1
|
1240
|
+
# BigDecimal('2.0') # => 0.2e1
|
1241
|
+
# BigDecimal('0.2e1') # => 0.2e1
|
1242
|
+
# BigDecimal(' 2.0 ') # => 0.2e1
|
1243
|
+
#
|
1244
|
+
# * Other type that responds to method `:to_str`: first converted to a string,
|
1245
|
+
# then converted to a BigDecimal, as above.
|
1246
|
+
#
|
1247
|
+
# * Other type:
|
1248
|
+
#
|
1249
|
+
# * Raises an exception if keyword argument `exception` is `true`.
|
1250
|
+
# * Returns `nil` if keyword argument `exception` is `false`.
|
1251
|
+
#
|
1252
|
+
# Raises an exception if `value` evaluates to a Float and `digits` is larger
|
1253
|
+
# than Float::DIG + 1.
|
1254
|
+
#
|
1255
|
+
def self?.BigDecimal: (real | string | BigDecimal initial, ?int digits, ?exception: bool) -> BigDecimal
|
1256
|
+
end
|
1257
|
+
|
1258
|
+
%a{annotate:rdoc:skip}
|
1259
|
+
class Integer
|
1260
|
+
# <!--
|
1261
|
+
# rdoc-file=ext/bigdecimal/lib/bigdecimal/util.rb
|
1262
|
+
# - int.to_d -> bigdecimal
|
1263
|
+
# -->
|
1264
|
+
# Returns the value of `int` as a BigDecimal.
|
1265
|
+
#
|
1266
|
+
# require 'bigdecimal'
|
1267
|
+
# require 'bigdecimal/util'
|
1268
|
+
#
|
1269
|
+
# 42.to_d # => 0.42e2
|
1270
|
+
#
|
1271
|
+
# See also Kernel.BigDecimal.
|
1272
|
+
#
|
1273
|
+
def to_d: () -> BigDecimal
|
1274
|
+
|
1275
|
+
# <!--
|
1276
|
+
# rdoc-file=numeric.c
|
1277
|
+
# - self / numeric -> numeric_result
|
1278
|
+
# -->
|
1279
|
+
# Performs division; for integer `numeric`, truncates the result to an integer:
|
1280
|
+
#
|
1281
|
+
# 4 / 3 # => 1
|
1282
|
+
# 4 / -3 # => -2
|
1283
|
+
# -4 / 3 # => -2
|
1284
|
+
# -4 / -3 # => 1
|
1285
|
+
#
|
1286
|
+
# For other +numeric+, returns non-integer result:
|
1287
|
+
#
|
1288
|
+
# 4 / 3.0 # => 1.3333333333333333
|
1289
|
+
# 4 / Rational(3, 1) # => (4/3)
|
1290
|
+
# 4 / Complex(3, 0) # => ((4/3)+0i)
|
1291
|
+
#
|
1292
|
+
def /: (BigDecimal) -> BigDecimal
|
1293
|
+
| ...
|
1294
|
+
|
1295
|
+
# <!--
|
1296
|
+
# rdoc-file=numeric.c
|
1297
|
+
# - self * numeric -> numeric_result
|
1298
|
+
# -->
|
1299
|
+
# Performs multiplication:
|
1300
|
+
#
|
1301
|
+
# 4 * 2 # => 8
|
1302
|
+
# 4 * -2 # => -8
|
1303
|
+
# -4 * 2 # => -8
|
1304
|
+
# 4 * 2.0 # => 8.0
|
1305
|
+
# 4 * Rational(1, 3) # => (4/3)
|
1306
|
+
# 4 * Complex(2, 0) # => (8+0i)
|
1307
|
+
#
|
1308
|
+
def *: (BigDecimal) -> BigDecimal
|
1309
|
+
| ...
|
1310
|
+
|
1311
|
+
# <!--
|
1312
|
+
# rdoc-file=numeric.c
|
1313
|
+
# - self + numeric -> numeric_result
|
1314
|
+
# -->
|
1315
|
+
# Performs addition:
|
1316
|
+
#
|
1317
|
+
# 2 + 2 # => 4
|
1318
|
+
# -2 + 2 # => 0
|
1319
|
+
# -2 + -2 # => -4
|
1320
|
+
# 2 + 2.0 # => 4.0
|
1321
|
+
# 2 + Rational(2, 1) # => (4/1)
|
1322
|
+
# 2 + Complex(2, 0) # => (4+0i)
|
1323
|
+
#
|
1324
|
+
def +: (BigDecimal) -> BigDecimal
|
1325
|
+
| ...
|
1326
|
+
|
1327
|
+
# <!--
|
1328
|
+
# rdoc-file=numeric.c
|
1329
|
+
# - self - numeric -> numeric_result
|
1330
|
+
# -->
|
1331
|
+
# Performs subtraction:
|
1332
|
+
#
|
1333
|
+
# 4 - 2 # => 2
|
1334
|
+
# -4 - 2 # => -6
|
1335
|
+
# -4 - -2 # => -2
|
1336
|
+
# 4 - 2.0 # => 2.0
|
1337
|
+
# 4 - Rational(2, 1) # => (2/1)
|
1338
|
+
# 4 - Complex(2, 0) # => (2+0i)
|
1339
|
+
#
|
1340
|
+
def -: (BigDecimal) -> BigDecimal
|
1341
|
+
| ...
|
1342
|
+
end
|
1343
|
+
|
1344
|
+
%a{annotate:rdoc:skip}
|
1345
|
+
class Float
|
1346
|
+
# <!--
|
1347
|
+
# rdoc-file=ext/bigdecimal/lib/bigdecimal/util.rb
|
1348
|
+
# - float.to_d -> bigdecimal
|
1349
|
+
# - float.to_d(precision) -> bigdecimal
|
1350
|
+
# -->
|
1351
|
+
# Returns the value of `float` as a BigDecimal. The `precision` parameter is
|
1352
|
+
# used to determine the number of significant digits for the result. When
|
1353
|
+
# `precision` is set to `0`, the number of digits to represent the float being
|
1354
|
+
# converted is determined automatically. The default `precision` is `0`.
|
1355
|
+
#
|
1356
|
+
# require 'bigdecimal'
|
1357
|
+
# require 'bigdecimal/util'
|
1358
|
+
#
|
1359
|
+
# 0.5.to_d # => 0.5e0
|
1360
|
+
# 1.234.to_d # => 0.1234e1
|
1361
|
+
# 1.234.to_d(2) # => 0.12e1
|
1362
|
+
#
|
1363
|
+
# See also Kernel.BigDecimal.
|
1364
|
+
#
|
1365
|
+
def to_d: (?Integer precision) -> BigDecimal
|
1366
|
+
|
1367
|
+
# <!--
|
1368
|
+
# rdoc-file=numeric.c
|
1369
|
+
# - self / other -> numeric
|
1370
|
+
# -->
|
1371
|
+
# Returns a new Float which is the result of dividing `self` by `other`:
|
1372
|
+
#
|
1373
|
+
# f = 3.14
|
1374
|
+
# f / 2 # => 1.57
|
1375
|
+
# f / 2.0 # => 1.57
|
1376
|
+
# f / Rational(2, 1) # => 1.57
|
1377
|
+
# f / Complex(2, 0) # => (1.57+0.0i)
|
1378
|
+
#
|
1379
|
+
def /: (BigDecimal) -> BigDecimal
|
1380
|
+
| ...
|
1381
|
+
|
1382
|
+
# <!--
|
1383
|
+
# rdoc-file=numeric.c
|
1384
|
+
# - self * other -> numeric
|
1385
|
+
# -->
|
1386
|
+
# Returns a new Float which is the product of `self` and `other`:
|
1387
|
+
#
|
1388
|
+
# f = 3.14
|
1389
|
+
# f * 2 # => 6.28
|
1390
|
+
# f * 2.0 # => 6.28
|
1391
|
+
# f * Rational(1, 2) # => 1.57
|
1392
|
+
# f * Complex(2, 0) # => (6.28+0.0i)
|
1393
|
+
#
|
1394
|
+
def *: (BigDecimal) -> BigDecimal
|
1395
|
+
| ...
|
1396
|
+
|
1397
|
+
# <!--
|
1398
|
+
# rdoc-file=numeric.c
|
1399
|
+
# - self + other -> numeric
|
1400
|
+
# -->
|
1401
|
+
# Returns a new Float which is the sum of `self` and `other`:
|
1402
|
+
#
|
1403
|
+
# f = 3.14
|
1404
|
+
# f + 1 # => 4.140000000000001
|
1405
|
+
# f + 1.0 # => 4.140000000000001
|
1406
|
+
# f + Rational(1, 1) # => 4.140000000000001
|
1407
|
+
# f + Complex(1, 0) # => (4.140000000000001+0i)
|
1408
|
+
#
|
1409
|
+
def +: (BigDecimal) -> BigDecimal
|
1410
|
+
| ...
|
1411
|
+
|
1412
|
+
# <!--
|
1413
|
+
# rdoc-file=numeric.c
|
1414
|
+
# - self - other -> numeric
|
1415
|
+
# -->
|
1416
|
+
# Returns a new Float which is the difference of `self` and `other`:
|
1417
|
+
#
|
1418
|
+
# f = 3.14
|
1419
|
+
# f - 1 # => 2.14
|
1420
|
+
# f - 1.0 # => 2.14
|
1421
|
+
# f - Rational(1, 1) # => 2.14
|
1422
|
+
# f - Complex(1, 0) # => (2.14+0i)
|
1423
|
+
#
|
1424
|
+
def -: (BigDecimal) -> BigDecimal
|
1425
|
+
| ...
|
1426
|
+
end
|
1427
|
+
|
1428
|
+
%a{annotate:rdoc:skip}
|
1429
|
+
class String
|
1430
|
+
# <!--
|
1431
|
+
# rdoc-file=ext/bigdecimal/lib/bigdecimal/util.rb
|
1432
|
+
# - str.to_d -> bigdecimal
|
1433
|
+
# -->
|
1434
|
+
# Returns the result of interpreting leading characters in `str` as a
|
1435
|
+
# BigDecimal.
|
1436
|
+
#
|
1437
|
+
# require 'bigdecimal'
|
1438
|
+
# require 'bigdecimal/util'
|
1439
|
+
#
|
1440
|
+
# "0.5".to_d # => 0.5e0
|
1441
|
+
# "123.45e1".to_d # => 0.12345e4
|
1442
|
+
# "45.67 degrees".to_d # => 0.4567e2
|
1443
|
+
#
|
1444
|
+
# See also Kernel.BigDecimal.
|
1445
|
+
#
|
1446
|
+
def to_d: () -> BigDecimal
|
1447
|
+
end
|
1448
|
+
|
1449
|
+
%a{annotate:rdoc:skip}
|
1450
|
+
class Rational
|
1451
|
+
# <!--
|
1452
|
+
# rdoc-file=ext/bigdecimal/lib/bigdecimal/util.rb
|
1453
|
+
# - rat.to_d(precision) -> bigdecimal
|
1454
|
+
# -->
|
1455
|
+
# Returns the value as a BigDecimal.
|
1456
|
+
#
|
1457
|
+
# The required `precision` parameter is used to determine the number of
|
1458
|
+
# significant digits for the result.
|
1459
|
+
#
|
1460
|
+
# require 'bigdecimal'
|
1461
|
+
# require 'bigdecimal/util'
|
1462
|
+
#
|
1463
|
+
# Rational(22, 7).to_d(3) # => 0.314e1
|
1464
|
+
#
|
1465
|
+
# See also Kernel.BigDecimal.
|
1466
|
+
#
|
1467
|
+
def to_d: (Integer precision) -> BigDecimal
|
1468
|
+
|
1469
|
+
# <!--
|
1470
|
+
# rdoc-file=rational.c
|
1471
|
+
# - rat / numeric -> numeric
|
1472
|
+
# - rat.quo(numeric) -> numeric
|
1473
|
+
# -->
|
1474
|
+
# Performs division.
|
1475
|
+
#
|
1476
|
+
# Rational(2, 3) / Rational(2, 3) #=> (1/1)
|
1477
|
+
# Rational(900) / Rational(1) #=> (900/1)
|
1478
|
+
# Rational(-2, 9) / Rational(-9, 2) #=> (4/81)
|
1479
|
+
# Rational(9, 8) / 4 #=> (9/32)
|
1480
|
+
# Rational(20, 9) / 9.8 #=> 0.22675736961451246
|
1481
|
+
#
|
1482
|
+
def /: (BigDecimal) -> BigDecimal
|
1483
|
+
| ...
|
1484
|
+
|
1485
|
+
# <!--
|
1486
|
+
# rdoc-file=rational.c
|
1487
|
+
# - rat * numeric -> numeric
|
1488
|
+
# -->
|
1489
|
+
# Performs multiplication.
|
1490
|
+
#
|
1491
|
+
# Rational(2, 3) * Rational(2, 3) #=> (4/9)
|
1492
|
+
# Rational(900) * Rational(1) #=> (900/1)
|
1493
|
+
# Rational(-2, 9) * Rational(-9, 2) #=> (1/1)
|
1494
|
+
# Rational(9, 8) * 4 #=> (9/2)
|
1495
|
+
# Rational(20, 9) * 9.8 #=> 21.77777777777778
|
1496
|
+
#
|
1497
|
+
def *: (BigDecimal) -> BigDecimal
|
1498
|
+
| ...
|
1499
|
+
|
1500
|
+
# <!--
|
1501
|
+
# rdoc-file=rational.c
|
1502
|
+
# - rat + numeric -> numeric
|
1503
|
+
# -->
|
1504
|
+
# Performs addition.
|
1505
|
+
#
|
1506
|
+
# Rational(2, 3) + Rational(2, 3) #=> (4/3)
|
1507
|
+
# Rational(900) + Rational(1) #=> (901/1)
|
1508
|
+
# Rational(-2, 9) + Rational(-9, 2) #=> (-85/18)
|
1509
|
+
# Rational(9, 8) + 4 #=> (41/8)
|
1510
|
+
# Rational(20, 9) + 9.8 #=> 12.022222222222222
|
1511
|
+
#
|
1512
|
+
def +: (BigDecimal) -> BigDecimal
|
1513
|
+
| ...
|
1514
|
+
|
1515
|
+
# <!--
|
1516
|
+
# rdoc-file=rational.c
|
1517
|
+
# - rat - numeric -> numeric
|
1518
|
+
# -->
|
1519
|
+
# Performs subtraction.
|
1520
|
+
#
|
1521
|
+
# Rational(2, 3) - Rational(2, 3) #=> (0/1)
|
1522
|
+
# Rational(900) - Rational(1) #=> (899/1)
|
1523
|
+
# Rational(-2, 9) - Rational(-9, 2) #=> (77/18)
|
1524
|
+
# Rational(9, 8) - 4 #=> (-23/8)
|
1525
|
+
# Rational(20, 9) - 9.8 #=> -7.577777777777778
|
1526
|
+
#
|
1527
|
+
def -: (BigDecimal) -> BigDecimal
|
1528
|
+
| ...
|
1529
|
+
end
|
1530
|
+
|
1531
|
+
%a{annotate:rdoc:skip}
|
1532
|
+
class Complex
|
1533
|
+
# <!--
|
1534
|
+
# rdoc-file=ext/bigdecimal/lib/bigdecimal/util.rb
|
1535
|
+
# - cmp.to_d -> bigdecimal
|
1536
|
+
# - cmp.to_d(precision) -> bigdecimal
|
1537
|
+
# -->
|
1538
|
+
# Returns the value as a BigDecimal.
|
1539
|
+
#
|
1540
|
+
# The `precision` parameter is required for a rational complex number. This
|
1541
|
+
# parameter is used to determine the number of significant digits for the
|
1542
|
+
# result.
|
1543
|
+
#
|
1544
|
+
# require 'bigdecimal'
|
1545
|
+
# require 'bigdecimal/util'
|
1546
|
+
#
|
1547
|
+
# Complex(0.1234567, 0).to_d(4) # => 0.1235e0
|
1548
|
+
# Complex(Rational(22, 7), 0).to_d(3) # => 0.314e1
|
1549
|
+
#
|
1550
|
+
# See also Kernel.BigDecimal.
|
1551
|
+
#
|
1552
|
+
def to_d: (*untyped args) -> BigDecimal
|
1553
|
+
|
1554
|
+
# <!--
|
1555
|
+
# rdoc-file=complex.c
|
1556
|
+
# - complex / numeric -> new_complex
|
1557
|
+
# -->
|
1558
|
+
# Returns the quotient of `self` and `numeric`:
|
1559
|
+
#
|
1560
|
+
# Complex.rect(2, 3) / Complex.rect(2, 3) # => (1+0i)
|
1561
|
+
# Complex.rect(900) / Complex.rect(1) # => (900+0i)
|
1562
|
+
# Complex.rect(-2, 9) / Complex.rect(-9, 2) # => ((36/85)-(77/85)*i)
|
1563
|
+
# Complex.rect(9, 8) / 4 # => ((9/4)+2i)
|
1564
|
+
# Complex.rect(20, 9) / 9.8 # => (2.0408163265306123+0.9183673469387754i)
|
1565
|
+
#
|
1566
|
+
def /: (BigDecimal) -> Complex
|
1567
|
+
| ...
|
1568
|
+
|
1569
|
+
# <!--
|
1570
|
+
# rdoc-file=complex.c
|
1571
|
+
# - complex * numeric -> new_complex
|
1572
|
+
# -->
|
1573
|
+
# Returns the product of `self` and `numeric`:
|
1574
|
+
#
|
1575
|
+
# Complex.rect(2, 3) * Complex.rect(2, 3) # => (-5+12i)
|
1576
|
+
# Complex.rect(900) * Complex.rect(1) # => (900+0i)
|
1577
|
+
# Complex.rect(-2, 9) * Complex.rect(-9, 2) # => (0-85i)
|
1578
|
+
# Complex.rect(9, 8) * 4 # => (36+32i)
|
1579
|
+
# Complex.rect(20, 9) * 9.8 # => (196.0+88.2i)
|
1580
|
+
#
|
1581
|
+
def *: (BigDecimal) -> Complex
|
1582
|
+
| ...
|
1583
|
+
|
1584
|
+
# <!--
|
1585
|
+
# rdoc-file=complex.c
|
1586
|
+
# - complex + numeric -> new_complex
|
1587
|
+
# -->
|
1588
|
+
# Returns the sum of `self` and `numeric`:
|
1589
|
+
#
|
1590
|
+
# Complex.rect(2, 3) + Complex.rect(2, 3) # => (4+6i)
|
1591
|
+
# Complex.rect(900) + Complex.rect(1) # => (901+0i)
|
1592
|
+
# Complex.rect(-2, 9) + Complex.rect(-9, 2) # => (-11+11i)
|
1593
|
+
# Complex.rect(9, 8) + 4 # => (13+8i)
|
1594
|
+
# Complex.rect(20, 9) + 9.8 # => (29.8+9i)
|
1595
|
+
#
|
1596
|
+
def +: (BigDecimal) -> Complex
|
1597
|
+
| ...
|
1598
|
+
|
1599
|
+
# <!--
|
1600
|
+
# rdoc-file=complex.c
|
1601
|
+
# - complex - numeric -> new_complex
|
1602
|
+
# -->
|
1603
|
+
# Returns the difference of `self` and `numeric`:
|
1604
|
+
#
|
1605
|
+
# Complex.rect(2, 3) - Complex.rect(2, 3) # => (0+0i)
|
1606
|
+
# Complex.rect(900) - Complex.rect(1) # => (899+0i)
|
1607
|
+
# Complex.rect(-2, 9) - Complex.rect(-9, 2) # => (7+7i)
|
1608
|
+
# Complex.rect(9, 8) - 4 # => (5+8i)
|
1609
|
+
# Complex.rect(20, 9) - 9.8 # => (10.2+9i)
|
1610
|
+
#
|
1611
|
+
def -: (BigDecimal) -> Complex
|
1612
|
+
| ...
|
1613
|
+
end
|
1614
|
+
|
1615
|
+
%a{annotate:rdoc:skip}
|
1616
|
+
class NilClass
|
1617
|
+
# <!--
|
1618
|
+
# rdoc-file=ext/bigdecimal/lib/bigdecimal/util.rb
|
1619
|
+
# - nil.to_d -> bigdecimal
|
1620
|
+
# -->
|
1621
|
+
# Returns nil represented as a BigDecimal.
|
1622
|
+
#
|
1623
|
+
# require 'bigdecimal'
|
1624
|
+
# require 'bigdecimal/util'
|
1625
|
+
#
|
1626
|
+
# nil.to_d # => 0.0
|
1627
|
+
#
|
1628
|
+
def to_d: () -> BigDecimal
|
1629
|
+
end
|